qiuyouzhi 发表于 2020-3-31 13:02:53

Python 查询论坛用户信息

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()

代码写的还是有点丑,思路来源于 一个账号 ,

特此感谢!
页: [1]
查看完整版本: Python 查询论坛用户信息