Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用python登录并绕过Cloudfare_Python_Parsing_Session - Fatal编程技术网

使用python登录并绕过Cloudfare

使用python登录并绕过Cloudfare,python,parsing,session,Python,Parsing,Session,我试图通过使用cfscrap绕过Cloudfare,然后登录来解析一个网站 我刚开始使用python,所以我不了解这些库是如何工作的。有没有办法把它们结合起来 from lxml import html import requests from requests import session import cfscrape payload = { 'username': 'myUsername', 'password': 'myPassword' } with session

我试图通过使用
cfscrap
绕过Cloudfare,然后登录来解析一个网站

我刚开始使用python,所以我不了解这些库是如何工作的。有没有办法把它们结合起来

from lxml import html
import requests
from requests import session
import cfscrape

payload = {
    'username': 'myUsername',
    'password': 'myPassword'
}

with session() as scraper:

    scraper = cfscrape.CloudflareScraper()
    scraper.post('http://kissanime.to/Login', data=payload)
    page = scraper.get('http://kissanime.to')
    page_tree = html.fromstring(page.content)

    check_login = page_tree.xpath('//a[@id="aDropDown"]/span/text()')
    not_logged_in = page_tree.xpath('//a[@href="http://kissanime.to/Login"]/text()')

    print check_login
    print not_logged_in
如果我成功登录,
check\u login
应该返回
myUsername