【问题标题】:How to open multiple links and extract table data from these links in Python?如何在 Python 中打开多个链接并从这些链接中提取表格数据?
【发布时间】:2018-07-19 17:46:02
【问题描述】:

第一行的所有元素都是指向后续页面的链接,我需要从中获取信息。主要问题是在 python 中打开这些链接。稍后我需要将该信息打印到 csv 文件中。 Here is image how it looks。 如何在 Python 中打开多个链接?谢谢

【问题讨论】:

  • 看看scrapy。

标签: python html csv href export-to-csv


【解决方案1】:

requestsbeautifulsoup 将轻松完成这项工作

import requests
from bs4 import BeautifulSoup


page = requests.get('http://firstpage.com/').text
soup = BeautifulSoup(page, 'html.parser')
links = soup.find_all('a')
for link in links:
    print(link['href'])

http://docs.python-requests.org/en/master/ https://www.crummy.com/software/BeautifulSoup/bs4/doc/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多