我有一个网络爬虫,用来解析用户输入的url。到目前为止,我已经完成了这项任务,我可以打印出url的源代码。现在我需要完成它。我需要显示网页中包含的所有网址的标题。例如,如果用户想要解析纽约时报,bot将显示页面上包含的所有指向其他url的标题。比如“最佳感恩节食谱”等等,我的代码是:
import urllib2
website = raw_input('Enter the website url: ')
getwebsite = urllib2.urlopen(website)
readwebsite = getwebsite.read()
print readwebsite
您可以使用BeautifulSoup提取所有链接:
使用您自己的代码:
^{pr2}$相关问题 更多 >
编程相关推荐