Fazlul

Untitled

Jun 18th, 2021
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. import scrapy
  2.  
  3. import json
  4.  
  5. class CardsSpider(scrapy.Spider):
  6.  
  7. name = 'cards'
  8. #body= Here is the formdata viewsource as string. As it so long, so pastebin is not accepting.
  9.  
  10. #based_url='https://moneyfacts.co.uk/credit-cards/balance-transfer-credit-cards/?fbclid=IwAR05-Sa1hIcYTRx8DXYYQd0UfDRjWF-jD2-u51jiLP-WKlkxSddKjzUcnWA'
  11.  
  12. def start_requests(self):
  13. yield scrapy.FormRequest(
  14. url = 'https://moneyfacts.co.uk/umbraco/surface/CreditCardsFinder/GetTableItemsFor',
  15. callback = self.parse,
  16. #body = self.body,
  17. method = "POST",
  18. headers = {
  19. 'content-type': 'application/x-www-form-urlencoded',
  20. 'content-length': 116213,
  21. 'x-requested-with': 'XMLHttpRequest',
  22. 'referer':'https://moneyfacts.co.uk/credit-cards/balance-transfer-credit-cards/?fbclid=IwAR05-Sa1hIcYTRx8DXYYQd0UfDRjWF-jD2-u51jiLP-WKlkxSddKjzUcnWA'
  23. }
  24. )
  25. def parse(self, response):
  26. for card in response.xpath('//ul[@class="finder-table"]/li'):
  27. card_name = card.xpath('.//*[@class="table-item-heading-product-name"]/span/strong/text()').get()
  28. yield{
  29. 'Name':card_name}
  30.  
Advertisement
Add Comment
Please, Sign In to add comment