【发布时间】:2015-06-10 02:09:57
【问题描述】:
我是 python 新手。我正在为我工作的公司构建一个爬虫。爬取它的网站,有一个内部链接不是它习惯的链接格式。如何获取整个链接而不是仅获取目录。如果我不太清楚,请运行我制作的代码:
import urllib2
from bs4 import BeautifulSoup
web_page_string = []
def get_first_page(seed):
response = urllib2.urlopen(seed)
web_page = response.read()
soup = BeautifulSoup(web_page)
for link in soup.find_all('a'):
print (link.get('href'))
print soup
print get_first_page('http://www.fashionroom.com.br')
print web_page_string
【问题讨论】:
-
整个链接是什么意思?
-
print seed + '/' + link.get('href')? -
我想在上面的案例中获得 htt://www.fashionroom.com.br/indexnew.html。相反,我刚刚得到了 indexnew.html
标签: python web-scraping beautifulsoup web-crawler