第一次写博客,主要是记录自己学习的过程,代码中有很多冗余的地方
先保证程序能成功运行
import re import urllib.request import os from easygui import * from time import sleep def url_open(url):#打开url req=urllib.request.Request(url) req.add_header('User-Agent','Mozilla/5.0 (Windows NT 6.1; rv:51.0) Gecko/20100101 Firefox/51.0') res=urllib.request.urlopen(req) html=res.read() return html def hmoe_uid(url): #获取首页用户的UID html=url_open(url).decode('utf-8') id=r'class="Avatar" href="/member-(.*?)-1"' uids=re.findall(id,html) del uids[0] return uids def trends_url(url,uid): #获取动态接口 tren_url=url+'/member-'+str(uid)+'-1' html=url_open(tren_url).decode('utf-8') a=html.find('aj-scroll="') b=html.find(