Skip to content

Instantly share code, notes, and snippets.

@lobstrio
Created March 2, 2018 12:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lobstrio/c83bf0791fdb1f674257765d1fa5dd18 to your computer and use it in GitHub Desktop.
Save lobstrio/c83bf0791fdb1f674257765d1fa5dd18 to your computer and use it in GitHub Desktop.
Python 3 code to scrape leboncoin "chalet" items in Savoie through Scrapy library
import scrapy
import time
class LbcSpider(scrapy.Spider):
name = "chalet_savoie_lbc"
start_urls = [
'https://www.leboncoin.fr/locations_gites/offres/rhone_alpes/savoie/',
]
def parse(self, response):
for annonce in response.css('a.list_item.clearfix.trackable'):
yield {
'titre': annonce.css('h2.item_title::text').extract_first(),
'prix': annonce.css('h3.item_price::text').extract_first(),
'lieu': annonce.css('p.item_supp::text').extract(),
}
time.sleep(0.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment