I have a question regarding Python error.
I'm trying to get data through web scraping, but I made an error when I tried to code it in the way below. What should I do?
I'd appreciate it if you could answer me.
import pandas as pd
import requests
from bs4 import BeautifulSoup
from datetime import datetime
import numpy as np
code = '298000'
fs_rpt_url = "http://comp.fnguide.com/SVO2/ASP/SVD_Finance.asp?pGB=1&gicode=A{}&cID=&MenuYn=Y&ReportGB=&NewMenuID=103&stkGb=701".format(code)
fs_rpt_res = requests.get(fs_rpt_url)
soup = BeautifulSoup(fs_rpt_res.text, "lxml")
data_rows = soup.find("table", attrs = {"class":"us_table_ty1 h_fix zigbg_no"}).find("thead").find_all("tr")
for row in data_rows:
columns = data_rows.find_all("th")
row_data = [column.get_text().strip() for column in columns]
print(row_data)
AttributeError: ResultSet object has no attribute 'find_all'. You're probably treating a list of elements like a single element. Did you call find_all() when you meant to call find()?
python beautifulsoup
Try printing except for .find_all("tr"). There is no tr.
data_rows = soup.find("table", attrs = {"class":"us_table_ty1 h_fix zigbg_no"}).find("thead")
566 Understanding How to Configure Google API Key
563 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
586 GDB gets version error when attempting to debug with the Presense SDK (IDE)
849 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.