Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
73 views
in Technique[技术] by (71.8m points)

python - Extracting a specific href from table

I'm trying to extract the "10-K" url and append it into a list from the following site:

https://www.sec.gov/Archives/edgar/data/320193/000091205701544436/0000912057-01-544436-index.htm

Picture 1 my code

So basically I'm trying to extract the first under the first that does not have as its sub category.

Am trying to create a loop to loop this code in multiple similar-like links, but guess I'm trying to resolve this issue first for now.

Any ideas?

question from:https://stackoverflow.com/questions/65713723/extracting-a-specific-href-from-table

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Hope this answers your requirement.

import requests
from bs4 import BeautifulSoup

URL = "https://www.sec.gov/Archives/edgar/data/320193/000091205701544436/0000912057-01-544436-index.htm"
page = requests.get(URL)

soup = BeautifulSoup(page.content, "html.parser")

rows = soup.findAll("td")

href_list = []
for ele in rows:
    a_Tag = ele.findChildren("a")
    if a_Tag:
        href_list.append(a_Tag)

print(href_list)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...