close

在 PTT 使用 POST 送資訊給網站

 

==============================

import requests
from bs4 import BeautifulSoup
playload = {"from":"/bbs/Gossiping/index.html","yes":"yes"}

re = requests.session()
res =re.post("https://www.ptt.cc/ask/over18",verify=False,data=playload)
res =re.get("https://www.ptt.cc/bbs/Gossiping/index.html",verify=False)

html= res.text
soup = BeautifulSoup(html,"lxml")

print("=================start=================") 
for aaa in soup.select(".r-ent"):
    print (aaa.select(".date")[0].text,aaa.select(".author")[0].text,aaa.select(".title")[0].text)

 


print( aaa.select(".date") )                                                                                              # [<div class="date"> 6/01</div>] ,Type : LIST
print( aaa.select(".date")[0].text )                                                                                   # 6/01

==============================

 

 

 

參考 :

https://mugglecoding.gitbooks.io/qa/content/findallhe_select_de_qu_bie.html

http://www.largitdata.com/

 

 

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 ricky10116r2d2 的頭像
    ricky10116r2d2

    ricky10116r2d2的部落格

    ricky10116r2d2 發表在 痞客邦 留言(0) 人氣()