【发布时间】:2020-09-11 23:47:29
【问题描述】:
我正在努力学习beautifulsoup。
在网站中,它具有相同的a href,但结果不同。
比如我的代码的结果是:
0001545654
6798
嗨
0001459640
发送
0001269765
加拿大
0001456527
加拿大
0001001379
GA
我只想带数字
数字的 URL = a href="/cgi-bin/browse-edgar?action=getcompany&CIK=0001545654&owner=exclude&count=40&hidefilings=0">0001545654
区域的 URL = a href="/cgi-bin/browse-edgar?action=getcompany&State=HI&owner=exclude&count=40&hidefilings=0">HI
我只想带CIK!
有什么办法只带CIK(0001545654)吗?
from selenium import webdriver
from bs4 import BeautifulSoup
from urllib.request import urlopen
url = 'https://www.sec.gov/cgi-bin/browse-edgar?company=a&owner=exclude&action=getcompany'
page = BeautifulSoup(urlopen(url), 'html.parser')
CIK = page.find('table', 'tableFile2').find_all('a')
#print(CIK)
for i in CIK:
print(i.get_text())
【问题讨论】:
标签: python url beautifulsoup web-crawler google-crawlers