Invalid Python requests agent

use the requests proxy module and do not change the ip address after success

< hr >

Code:

import requests
from bs4 import BeautifulSoup
url=r"http://ip.chinaz.com/"
proxy={"http": "http://177.130.55.164:20183",
       "https": "https://177.130.55.164:20183"}
html=requests.get(url,proxies=proxy,timeout=10)
html=BeautifulSoup(html.text,"lxml")
nr=html.select(".getlist")
print(nr)
Mar.02,2021

this agent IP has been invalidated, change to another agent IP test

import requests

url = 'http://ip.chinaz.com/getip.aspx'
proxy = {'http': 'http://177.130.55.164:20183',
         'https': 'https://177.130.55.164:20183'}

r = requests.get(url, proxies=proxy, timeout=1)
print r.text
Menu