bs4抓取python无法获得锚标记的完整href

时间:2018-09-05 05:56:56

标签: python beautifulsoup href scrape

我想使用此网站https://www.eduvision.edu.pk/institutions-detail.php?city=51I&institute=1310738526_national-defence-university-islamabad的类名=“ fixText”来刮除div中的锚标记的href,但无法获取完整的href文本。请帮帮我。
我只有一半的href “ institutions-detail.php?city = 51I&institute = 721_institute-of-space-technology-islamabad”

import requests  
from bs4 import BeautifulSoup  
from fake_useragent import  UserAgent  

ua = UserAgent()  
header = {'user-agent':ua.chrome}  
response = requests.get('https://www.eduvision.edu.pk/institutions-detail.php?city=51I&institute=1310738526_national-defence-university-islamabad',headers=header)  
soup = BeautifulSoup(response.content, 'html.parser')  
for i in soup.find_all('div', attrs={'class' : 'fixText'}): 
    print(i.a['href'])  

0 个答案:

没有答案