作者a856479 (thebelief)
看板Python
标题[问题] 爬虫 如何爬指定资料
时间Sat Feb 18 15:52:06 2017
大家好,由於我没有程式语言的基础
最近试着爬网页资料时遇到一个问题不知道怎麽解决
请求各位协助帮忙,谢谢!
目标网址:
https://goo.gl/02M292
目标资料:只要"今日十全战法偏多"里面出现的股票名称
问题:我找不出"今日十全战法偏多"的class或能定义它的方式,
导致只能抓取到网页内所有的股票名称...
----------以下是我目前的写法----------
import requests
from bs4 import BeautifulSoup
res = requests.get("
http://www.sohowgood.com/TwStock/PowerKLine.aspx")
soup = BeautifulSoup(res.text, "lxml")
stocks = soup.find_all('li')
for stock in stocks:
meta = stock.find('a')
stockid = meta.getText().strip()
print(stockid)
请问我该如何修改才能抓取到我需要的部分? 谢谢大家
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 218.187.129.44
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1487404329.A.3AD.html