ネットワーカー学習ログ(二)
3070 ワード
Task 2(2日間)
2.1 beautiful soupを学ぶはbeautiful soupを勉強して、beautiful soupを使って内容を抽出します。 Beautiful soupを使って丁香園フォーラムの回答内容を抽出します。 丁香園直通点:http://www.dxy.cn/bbs/thread/626626#626626 。 参考資料:https://blog.csdn.net/wwq114/article/details/88085875 *2.2学習xpath**はxpathを学び、lxml+xpathを使って内容を抽出する。 xpathを用いて丁香園フォーラムの回答内容を抽出する。 丁香園直通点:http://www.dxy.cn/bbs/thread/626626#626626 。 参考資料:https://blog.csdn.net/naonao77/article/details/88129994 2.1:
2.1 beautiful soupを学ぶ
import requests
from bs4 import BeautifulSoup as bs
headers={'User-Agent':'Mozilla/5.0 (Windows NT 6.1;Win64;x64) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/55.0.2883.87 Safari/537.36'}
resp=requests.get('http://www.dxy.cn/bbs/thread/626626#626626',headers=headers)
print(resp.status_code)
def getitem(html):
soup=bs(html,'lxml')
return soup.find_all('td',class_='postbody')
html=resp.text
item=getitem(html)
for i in range(len(item)):
print("--**--"*5)
print(item[i].text.strip())
2.2import requests
from lxml import etree
headers={'User-Agent':'Mozilla/5.0 (Windows NT 6.1;Win64;x64) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/55.0.2883.87 Safari/537.36'}
resp=requests.get('http://www.dxy.cn/bbs/thread/626626#626626',headers=headers)
print(resp.status_code)
def getitem(html):
html=etree.HTML(html)
return html.xpath('//td[@class="postbody"]//text()')
html=resp.text
item=getitem(html)
for i in range(len(item)):
print("--**--"*5)
print(item[i].strip())
:
html=resp.text
item=getitem(html)
for i in range(len(item)):
print("--**--"*5)
print(item[i].strip())
--**----**----**----**----**--
“ ” , 。 ,42 。 30 。 , 。 , , , 。 。 。 。ECG、24 ; MRI ; 。 。 , , ?
--**----**----**----**----**--
, 。 、ECG、UCG、holter X-ray 。
--**----**----**----**----**--
“ ”
--**----**----**----**----**--
:
--**----**----**----**----**--
http://www.ccheart.com.cn/ccheart_site/Templates/jieru/200011/1-1.htm
--**----**----**----**----**--
--**----**----**----**----**--
lion000 : , , 。
--**----**----**----**----**--
HOLTER , , 。 , , , , , 。
--**----**----**----**----**--
, , 。
--**----**----**----**----**--
1 , 、 、 , , 2002 Vol.28 No.2
--**----**----**----**----**--
, 。 , , , MIR(MRA), 。
今日は風邪を引いて勉強する気がないので、明日は説明します。