Python Forum

Full Version: Scraping problems. Pls help with a correct request query.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Please do not suggest SELENIUM solutions.

the request in this form does not return results.

def fg_list_bot(_name_element, _output_file):
    print(_name_element)
    s = requests.Session()
    _data = {"searchValue": _name_element,"searchSubmit":"submit[s][/s]"}
    _headers = {"User-Agent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0"}  
    r = requests.post(_url, data=_data, headers = _headers)
    with open(_output_file, "w", encoding='utf-8') as f:
        f.write(r.text)
    print(r.status_code)

#
# code beginn
#
import requests
from bs4 import BeautifulSoup
_url = "https://hifi-filter.com/en/catalog/recherche-equivalence.html"
_output_file = "IDLE_HIFI.html"
_name_element = "pi3115"   
fg_list_bot(_name_element, _output_file)
if I add captcha, as below, then it works for some time with different search parameters, when the captcha is fresh.
After some time it does not return results, like the first variant.

def fg_list_bot(_name_element, _output_file):
    print(_name_element)
    s = requests.Session()
_data = {"searchValue": _name_element,"searchSubmit":"submit",
             "g-recaptcha-response":"03AOLTBLSGgHKYeeU_WgH-tOhoUV8UXkBejUCAhxgfuyBKE0QA0PeDOcTlrhTd0zlhTyCVIjjkZrfxWBnBfd6R5_G_XU15ZN8s3nqHljYjvXMHpijXj4TZUIu0t_hBHu65rJb7op28Iz1EplJxP0lbfXJbm3Mif-O6jg-eXb-v_spSH4W2aW4nSvMMrHGy-7iJpOns4O-Ff-P2kit_E7jbrKF6jakyR1f0FlcLGFHAPNaf0w2BhnXvxlFmo6ghDR58jqJmWiRRj0BK8nAMIw0FVI4J1j3hoWDxxNX6bnHXxw-mQb-FEhwM4oHMVCvj-NqzG2gX__H9AXuSU7Ehnl9YwtMi3ssW6V4FuEmVIwpZDPy-nIfSdi7NyuycZj6tgLFyKfefj91oaWCNoNqH48I0MfE6zkfim7KlTfbG0LxGIFpH4MMH1_iNunJ0LJU9s_o8jUA3HP5bL-1jPVAbFC6pnxe07GmyKaSutQ"}    _headers = {"User-Agent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0"}  
    r = requests.post(_url, data=_data, headers = _headers)
    with open(_output_file, "w", encoding='utf-8') as f:
        f.write(r.text)
    print(r.status_code)

#
# code beginn
#
import requests
from bs4 import BeautifulSoup
_url = "https://hifi-filter.com/en/catalog/recherche-equivalence.html"
_output_file = "IDLE_HIFI.html"
_name_element = "pi3115"   
fg_list_bot(_name_element, _output_file)
[Image: q02.png]

Thank you !!!