马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
Python 查询论坛用户信息
from requests import get
from bs4 import BeautifulSoup as BS
def ourl(url):
return get(url)
def getInfo(res):
soup = BS(res.text, "html.parser")
target = soup.find_all("ul", class_ = "pf_l")
return target
def main():
while True:
uid = input("请输入用户UID(输入Q!退出):")
if uid == 'Q!':
break
url = 'https://fishc.com.cn/space-uid-%s.html' % uid
res = ourl(url)
targ = getInfo(res)
for each in targ:
if hasattr(each, "strings"):
print(''.join(each.strings))
if __name__ == "__main__":
main()
代码写的还是有点丑,思路来源于 一个账号 ,
特此感谢! |