using python crawler (1)

Step 1. This is a simple website and get into the target data

The first step: Import of urllib                  

import urllib.request

Step Two: Set URL address

url = 'http://45.32.164.128/ip.php'

The third step: # Open URL and accepting responses

response = urllib.request.urlopen(url)    

Step four: but received a response needs to be transcoded before you can read

html = response.read()

Step five: Print captured data

print(html)

 

2. If your site needs is data UTF-8 encoding is required

 

data = {}
#目标网站需要的数据
data['type'] = 'AUTO'
data['i'] = content
data['doctype'] = 'json'
data['version'] = 2.1
data['keyfrom'] = 'fanyi.web'
data['smartresult'] = 'dict'
data['client'] = 'fanyideskweb'
data['salt'] = '15831654231717'
data['sign'] = '791ac18e417f96ac327e66aacbc77bf2'
data['ts'] = '1583165423171'
data['bv'] = '0ed2e07b89acaa1301d499442c9fdf79'
data['action'] = 'FY_BY_REALTlME'

# Transcoding for text
data = urllib.parse.urlencode (data) .encode ( 'utf-8')

 

3. If you need website ban ip proxy IP

Three steps

 

Guess you like

Origin www.cnblogs.com/Alex0001/p/12409947.html