Home > Mobile >  How to use RegEx on Requests
How to use RegEx on Requests

Time:07-12

I am trying to extract all the prices available for search term on ebay for Page 1. However I can't seem to be able to get the prices.

import re
import requests

search_result = requests.get('https://www.ebay.co.uk/sch/i.html?_from=R40&_trksid=p2380057.m570.l1313&_nkw=air jordan 1 mid&_sacat=0')
result = search_result.text

price_finder = re.compile('^£......')
ebay_prices = price_finder.search(result)
print(ebay_prices)

When I run the program it just returns an empty list. I've tried even just using ^\d to find any string with a number (As I thought I was formatting wrong) but even then that returns nothing.

I've done print(result) and it prints out the entire results so I'm not sure what I'm doing wrong. Thanks

CodePudding user response:

You don't get the results because the page is not static but it is dynamic. This means that the data is not present within the basic html code of the page, but is dynamically generated. For dynamic website scraping you should use Selenium.

In fact if you try to do print(search_result.text), you will get the html code of the page, and if you try to read the code you will see that there are no prices of any product.

  • Related