from urllib import request
import re
def getResponse(url):
    url_request = request.Request(url)
    url_response = request.urlopen(url_request)
    return url_response
def getData(data):
    html = re.findall(r'alt="[\u4E00-\u9FA5\\s]+"',data)
    return html
aid = 1
for aid in range(1,123):
    html = "http://www.zhijiaow.com/ShopMallList_%s_0.html" %aid
    aid +=1    
    http_response = getResponse(html)
    data = http_response.read().decode('utf8')
    l = getData(data)
    global n
    n = 1
    for info in l:
        with open('c.txt','a') as f:
            f.write(info)
        n +=1
with open('c.txt','r') as f:
    lines = f.readlines()
with open('a.txt','a') as w:
    for l in lines:
        w.write(l.replace('"alt="','\n'))

 

相关文章:

  • 2021-11-11
  • 2022-02-24
  • 2022-01-18
  • 2021-11-23
  • 2022-12-23
  • 2021-08-02
  • 2022-02-13
猜你喜欢
  • 2021-09-03
  • 2021-08-19
  • 2021-11-28
  • 2022-12-23
  • 2021-05-13
  • 2021-04-18
  • 2021-11-19
相关资源
相似解决方案