模拟点击的网页抓取鬼.py

2024-10-05 11:03:02 发布

您现在位置:Python中文网/ 问答频道 /正文

我想抓取的网站有多个动态加载的页面,我想模拟点击(没有像selenium那样打开浏览器),所以我使用鬼.py. 在

这是一个简单的程序

from ghost import Ghost
import time

ghost = Ghost(wait_timeout=50)
page, extra_resources = ghost.open("http://www.samsung.com/in/consumer/mobile-phone/mobile-phone/viewall")
#ghost.wait_page_loaded()
n=2;
#links=ghost.evaluate("""
#           alist=document.getElementsById('txtViewAll');
#           alist.click;
#            """)
#print type(ghost.click("input#txtViewAll"))
page1, resources = ghost.evaluate("document.getElementById('txtViewAll').click();", expect_loading=True)
time.sleep(20)
print page1

但是

输出。在

有人能帮我解释一下程序出了什么问题吗。在

为什么不起作用?在


Tags: import程序timepagephonemobiledocumentclick

热门问题