Skip to content

Instantly share code, notes, and snippets.

@doroudi
Last active October 17, 2019 20:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doroudi/d57bc6685c30236dfcc1322c27ff6e50 to your computer and use it in GitHub Desktop.
Save doroudi/d57bc6685c30236dfcc1322c27ff6e50 to your computer and use it in GitHub Desktop.
Get Movies Information
# -*- coding: utf-8 -*-
import scrapy
class TopmoviesSpider(scrapy.Spider):
name = 'topMovies'
allowed_domains = ['imdb.com']
start_urls = ['https://www.imdb.com/chart/top/']
def parse(self, response):
movies = response.css(".lister-list tr")
for movie in movies:
yield {
'image': movie.css('.posterColumn img::attr(src)').extract_first(),
'title': movie.css('.titleColumn a::text').extract_first(),
'link': movie.css('.titleColumn a::text').extract_first(),
'rate': movie.css('.ratingColumn strong::text').extract_first()
}
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment