我想从网站获取一些数据,这需要登录。
我通过以下方式登录requests
url = "http://example.com"
response = requests.get(url, {"email":"[email protected] /cdn-cgi/l/email-protection", "password":"12345"})
cookies = response.cookies
然后我想从一些 JS 页面获取数据。通过requests这是不可能的,所以我必须使用干刮为了这。
import dryscrape
url = "http://example.com/js-page"
sess = dryscrape.Session()
sess.visit(url)
是否可以将cookie传递给visit()或者我必须寻找另一种解决方案?
为什么不通过 dryscrape 登录?
session = dryscrape.Session()
session.visit('<url_where_is_login_form>')
name = session.at_xpath('//*[@name="username"]') # Where <input name="username">
name.set("<login>")
password = session.at_xpath('//*[@name="password"]') # Where <input name="password">
password.set("<password>")
# Push the button
name.form().submit()
session.visit("<url to visit with proper cookies>")
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)