故里 发表于 2021-10-15 08:36:59

有没有办法进行这两个库的数据可视化


https://www.worldpresidentsdb.com/list/gender/male/
https://www.worldpresidentsdb.com/list/gender/female/
import requests
from lxml import etree


def main():
    base_url = 'https://www.worldpresidentsdb.com'
    url = 'https://www.worldpresidentsdb.com/list/gender/male/'
    headers = {'user-agent': 'firefox'}
    r = requests.get(url, headers=headers)
    html = etree.HTML(r.text)
    psts = html.xpath('//div[@class="list-group"]//@href')
    for pst in psts:
      url = f'{base_url}{pst}'
      r = requests.get(url, headers=headers)
      html = etree.HTML(r.text)
      info = html.xpath('//div/p//text()')
      print(info)


if __name__ == '__main__':
    main()

故里 发表于 2021-10-15 10:41:18

使用MySQL或者hadoop
页: [1]
查看完整版本: 有没有办法进行这两个库的数据可视化