为了账号安全,请及时绑定邮箱和手机立即绑定

老师,你好,帮我看看这个路由器管理界面的ip怎么抓取?

http://img1.sycdn.imooc.com//60a282b10001c38d10050526.jpg

http://img1.sycdn.imooc.com//60a282b10001f39712640833.jpg

1.通过get请求访问登录页面

http://172.18.21.254/login.htm


Request Headers:


GET /login.htm HTTP/1.1

Host: 172.18.21.254

Connection: keep-alive

Pragma: no-cache

Cache-Control: no-cache

Upgrade-Insecure-Requests: 1

User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9

Accept-Encoding: gzip, deflate

Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,zh-TW;q=0.6,und;q=0.5



输入账号密码点击登录


2. post访问页面(不知道为什么是post的根目录的?)

http://172.18.21.254/


Request Headers:


POST / HTTP/1.1

Host: 172.18.21.254

Connection: keep-alive

Content-Length: 71

Pragma: no-cache

Cache-Control: no-cache

Accept: text/plain, */*; q=0.01

X-Requested-With: XMLHttpRequest

User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36

Content-Type: application/json; charset=UTF-8

Origin: http://172.18.21.254

Referer: http://172.18.21.254/login.htm

Accept-Encoding: gzip, deflate

Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,zh-TW;q=0.6,und;q=0.5


Request Payload(这里出现了这个参数,而不是form data)

{"method":"do","login":{"username":"800","password":"42zK46b09TefbwK"}}



3.get http://172.18.21.254/ (这里为什么有发起了个get根目录的请求?)


Request Headers:


GET / HTTP/1.1

Host: 172.18.21.254

Connection: keep-alive

Pragma: no-cache

Cache-Control: no-cache

Upgrade-Insecure-Requests: 1

User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9

Referer: http://172.18.21.254/login.htm

Accept-Encoding: gzip, deflate

Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,zh-TW;q=0.6,und;q=0.5

最后我代码运行的结果是一堆报错。。。。

import requests


# requests.session,创建一个保持登录凭据的session实例

login_session = requests.session()

# 1、get请求,获取token信息

token_url = "http://172.18.21.254/login.htm"

header = {

    "Host": "172.18.21.254",

    "Connection": "keep-alive",

    "Pragma": "no-cache",

    "Cache-Control": "no-cache",

    "Upgrade-Insecure-Requests": "1",

    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36",

    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",

    "Accept-Encoding": "gzip, deflate",

    "Accept-Language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,zh-TW;q=0.6,und;q=0.5"

}


# 发送第一个get请求

# token_response = login_session.get(url=token_url, headers=header)

# # 通过正则表达式获取token值

# token_search = re.compile(r"XSRF-TOKEN=(.*?);")

# token_value = token_search.search(token_response.headers.get("Set-Cookie"))


# 2、post请求

login_url = "http://172.18.21.254/"

data = {

    "username": "800",

    "password": "42zK46b09TefbwK"

}


# 发送Post请求,提交用户名密码,注意不要忘记携带data

login_response = login_session.post(url=login_url, headers=header, data=data)

print(login_response.text)


index_url = "http://172.18.21.254/stok=a685d0393b95322ddeac24e58621c5d4/userrpm/system_state.htm"

# 一定要使用login_session

index_response = login_session.post(url=index_url, headers=header)

print(index_response.text)


正在回答

举报

0/150
提交
取消

老师,你好,帮我看看这个路由器管理界面的ip怎么抓取?

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信