Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.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请求_Python_Python Requests - Fatal编程技术网

使用元刷新的Python请求

使用元刷新的Python请求,python,python-requests,Python,Python Requests,您好,我尝试使用Python请求登录我的路由器Asus-AC52U,以使用以下脚本获取信息: import requests login_url = 'http://192.168.172.1/login.cgi' payload = {'loginSubmitValue':'1','admin_username':'user',"admin_password":"pw"} data_url = 'http://192.168.172.1/Advanced_VPNClient_Content.a

您好,我尝试使用Python请求登录我的路由器Asus-AC52U,以使用以下脚本获取信息:

import requests
login_url = 'http://192.168.172.1/login.cgi'
payload = {'loginSubmitValue':'1','admin_username':'user',"admin_password":"pw"}
data_url = 'http://192.168.172.1/Advanced_VPNClient_Content.asp'

s = requests.Session()
resp = s.post(data_url, data=payload, verify=False)

test = s.get(data_url)
print test.text
这是我得到的输出:

<meta http-equiv="refresh" content="0; url=/Main_Login.asp?page=/cgi-bin/Advanced_VPNClient_Content.asp">
</HEAD></HTML>

有人能告诉我,我必须做什么才能得到网页的源代码来刮取它的内容吗?或者我可以尝试做什么?

使用相同的代码:

import requests
data_url = 'Some url'
s = requests.Session()
test = s.get(data_url)
print (test.text)
要刮去这一页,你只需要在这一页上做“开始”。如果您想在登录后刮取页面,请尝试使用相同的代码组合post/get请求:

import requests
data_url = 'Some url'
s = requests.Session()
test = s.get(data_url)
print (test.text)
要刮去这一页,你只需要在这一页上做“开始”。如果您想在登录后刮取页面,请尝试组合post/get请求,您可以尝试以下操作:

import requests
response = requests.get('index.asp', verify=False) #web page to scrape
print(response.status_code)
print(response.content)
您可以尝试以下方法:

import requests
response = requests.get('index.asp', verify=False) #web page to scrape
print(response.status_code)
print(response.content)