2017-06-30 54 views
-1

靜態URL我要爬一個基於PHP的網站它有一個搜索框,我們可以輸入在搜索框中輸入數字抓取的網站,它呈現對輸入的號碼,結果當我們點擊提交按鈕或點擊輸入,但URL不會更改。 像其顯示foo.com/res_17.php每一個結果,但對於像爬行千餘記錄,記錄應該是唯一的ID,如foo.com/res_17.php?id=1001,foo.com/res_17訪問。 php?id = 1002 - foo.com/res_17.php?id = 3450,這樣我就可以使用while循環訪問它們了,我該如何做到這一點,任何解決方案,請幫助。如何具有蟒蛇

+0

你有什麼問題? –

+0

http://fbise.edu.pk/res-ssc-II.php本網站結果卷#100001-143293可如何抓取他們...? –

回答

0

我給你一個我的腳本

from urllib.request import urlopen 
from bs4 import BeautifulSoup 
import re 
html = urlopen("http://en.wikipedia.org/wiki/Andrew_Ng") 
bsObj = BeautifulSoup(html) 

for link in bsObj.find("div", {"id":"bodyContent"}).findAll("a", 
      href=re.compile("^(/wiki/)((?!:).)*$")): 
    if 'href' in link.attrs: 
     print(link.attrs['href']) 

輸出表示爲所有安德魯伍維基百科的文章。