爬Fishc的用户信息~
前几天见一个大佬写了一个爬全部用户的个人信息,我就心血来潮写了一个输入uid查询的,初学python,写的不好的地方请多指教{:10_254:}还有就是注释起来的爬取头衔和个性签名的部分,不知道为什么只能爬小甲鱼的,到别人就会报错,报错内容:IndexError: list index out of range
下面上代码:
static/image/hrline/1.gif
import requests
import re
'''
with open('fishc.txt','w') as g:
g.write(response.text)
'''
z = 1
def find_name():
reg_name = r'"keywords" content="(.*?)"'
find1 = re.findall(reg_name,response.text)
if find1 == '':
print('查无此人!')
global z
z = 0
else:
print('\t您现在看到的是:',find1)
def find_all():
'''
emile = r'<li><em>邮箱状态</em>(.{3})</li>'
find_emile = re.findall(emile,response.text)
print('\t邮箱状态:',find_emile)
gif = r'<li><em>视频认证</em>(.{3})</li>'
find_gif = re.findall(gif,response.text)
print('\t视频认证:',find_gif)
header = r'<em>自定义头衔 </em>(.*?)</li><li><em class="xg1">个人签名 </em><table><tr><td>(.*?)</td></tr>'
find_header = re.findall(header,response.text)
print('\t自定义头衔:',find_header,'\n\t个性签名:',find_header)
'''
friend = r'"_blank">好友数 (.*?)</a>'
find_friend = re.findall(friend,response.text)
print('\t好友数:',find_friend)
jilu = r'"_blank">记录数 (.*?)</a>'
find_jilu = re.findall(jilu,response.text)
print('\t记录数:',find_jilu)
rizhi = r'"_blank">日志数 (.*?)</a>'
find_rizhi = re.findall(rizhi,response.text)
print('\t日志数:',find_rizhi)
jpg = r'"_blank">相册数 (.*?)</a>'
find_jpg = re.findall(jpg,response.text)
print('\t相册数:',find_jpg)
return1 = r'"_blank">回帖数 (.*?)</a>'
find_return1 = re.findall(return1,response.text)
print('\t回帖数:',find_return1)
zhuti = r'"_blank">主题数 (.*?)</a>'
find_zhuti = re.findall(zhuti,response.text)
print('\t主题数:',find_zhuti)
fx = r'"_blank">分享数 (.*?)</a>'
find_fx = re.findall(fx,response.text)
print('\t分享数:',find_fx)
all = r'<li><em>(.*?)</em>(.*?)</li>'
find_all0 = re.findall(all,response.text)
for i in find_all0:
print('\t',i,':',i)
if __name__ == "__main__":
uid = input('请输入你要查询用户的UID:')
url = 'https://fishc.com.cn/space-uid-' + uid + '.html'
response = requests.get(url)
find_name()
if z == 0:
input('任意键继续...')
else:
find_all()
static/image/hrline/2.gif
{:10_247:} {:10_275:}
页:
[1]