如何使用scrapy-splash设置输入值?

时间:2019-08-01 04:34:17

标签: javascript python web-scraping scrapy scrapy-splash

我需要以一种形式设置输入值,获得响应后输入仍为空。

我试图将assert(splash:wait(1))设置为assert(splash:wait(10)),以等待页面加载,但是没有用:

script ="""
 function main(splash,args)
    assert(splash:go(args.url))
    assert(splash:wait(1))
    local entries = splash:history()
    local last_response = entries[#entries].response 
    assert(splash:runjs('document.getElementById("email").value = 
    "1dfsdfsdf@dsfs.Com4"'))
    assert(splash:runjs('document.getElementById("email").value ="54654")
    local element = splash:select('#verification_code')
    local bounds = element:bounds()
    assert(element:mouse_click{x=bounds.width/2, y=bounds.height/2})
    assert(splash:wait(1))
    return {
          url = splash:url(),
          headers = last_response.headers,
          http_status = last_response.status,
          cookies = splash:get_cookies(),
          html = splash:html(),
          email = splash:select("#email").node.outerHTML,
          phone = splash:select("#phone").node.outerHTML
   }
end 
"""

输入内容为空:

<input type="text" name="email" id="email"  value=""> <input type="text" name="phone" id="phone"  value="" >

0 个答案:

没有答案