데이터 마이닝을위한 데이터를 수집하기 위해 웹을 긁어 내고 싶습니다. 이 웹 데이터에는 43 페이지가있는 큰 테이블이 있습니다. 또한 확장 메뉴의 가장 오른쪽에있는 일부 주식을 숨 깁니다.R 또는 파이썬을 사용하여 여러 페이지로 웹 테이블을 긁는 방법
이 웹 페이지는 다음과 같습니다.
http://data.10jqka.com.cn/market/longhu/yyb/
import bs4
import requests
url = r"http://data.10jqka.com.cn/market/longhu/yyb/"
response = requests.get(url)
if response.status_code == 200:
content = response.content
soup = bs4.BeautifulSoup(content)
table_results = soup.findAll("table", {"class": "m_table"})
for item in table_results:
company_name = item.findAll("td", {"class": "tl"})[0].text.strip()
detail = item.findAll("td", {"class": "tc"})[0].text.strip()
c_rise = item.findAll("td", {"class": "c_rise"})[0].text.strip()
c_fall = item.findAll("td", {"class": "c_fall"})[0].text.strip()
cur = item.findAll("td", {"class": "cur"})[0].text.strip()
lhb_stocklist = item.findAll("div", {"class": "lhb_stocklist"})[0].text.strip()
print company_name, detail, c_rise, c_fall, lhb_stocklist
지금 무엇을 했습니까? 어떤 코드? – Eric
@ yan9yu, 나는 XML과 Curl로 R을 시도했다. Rcause에서는 R보다 더 강합니다. 그러나 나는 아직도이 테이블을 긁는 법을 모른다. 시도하면서 동시에 코드를 업데이트 할 것입니다. –
@ yan9yu 안녕하세요, 제게 손을 줘 주셔서 감사합니다! –