Skip to content

Instantly share code, notes, and snippets.

@khunreus
Last active February 13, 2019 13:26
Show Gist options
  • Save khunreus/bc5381eb6839081f8a4831c3f2f6ad28 to your computer and use it in GitHub Desktop.
Save khunreus/bc5381eb6839081f8a4831c3f2f6ad28 to your computer and use it in GitHub Desktop.
"""
python3.6
ipython console test
"""
from scrapy.selector import Selector
scrapy_selector = Selector(text = self.driver.page_source)
homes_selector = scrapy_selector.xpath('//*[@itemtype="http://schema.org/ListItem"]') #name of an item can be changed by Airbnb
try:
i = 0
j = 1
# q = 1
# p = 2
for home_selector in homes_selector:
url = home_selector.xpath('//*[@itemprop = "url"]/@content').extract()[i]
name = home_selector.xpath('//*[@itemprop="name"]/@content').extract()[i]
price_local = home_selector.xpath('//*[@class="_12kw8n71"]/span/text()').extract()[j]
rating = home_selector.xpath('//*[@class="_q27mtmr"]//@aria-label').extract()[i]
yield{
'url': url,
'name': name,
'price_local': price_local,
'rating': rating
}
i = i+1
j = j+2
except:
logger.info('Reached the last iteration')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment