Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #With BeautifulSoup
- items = [(x[0].text, x[0].get('href')) for x in
- filter(None, [
- x.findChildren() for x in
- soup.findAll('td', {'class':'title'})
- ])]
- for item in items:
- print item
- news_item = NewsItem()
- news_item['title'] = item[0]
- news_item['url'] = item[1]
- # Without using BeautifulSoup.
- for item in hxs.select('//td[@class="title"]/a'):
- news_item = NewsItem()
- news_item['title'] = item.select('text()').extract()[0]
- news_item['url'] = item.select('@href').extract()[0]
Advertisement
Add Comment
Please, Sign In to add comment