ValueError: invalid literal for int() with base 16: b” Python, BS4, Cloudscraper

  beautifulsoup, python, web-scraping

Im trying to get a URL using bs4 and cloudscraper, but I have the next errors

 _update_chunk_length
    self.chunk_left = int(line, 16)
ValueError: invalid literal for int() with base 16: b''
During handling of the above exception, another exception occurred:
urllib3.exceptions.InvalidChunkLength: InvalidChunkLength(got length b'', 0 bytes read)
During handling of the above exception, another exception occurred:
urllib3.exceptions.ProtocolError: ("Connection broken: InvalidChunkLength(got length b'', 0 bytes read)", InvalidChunkLength(got length b'', 0 bytes read))
During handling of the above exception, another exception occurred:
requests.exceptions.ChunkedEncodingError: ("Connection broken: InvalidChunkLength(got length b'', 0 bytes read)", InvalidChunkLength(got length b'', 0 bytes read))

My code its the next

import cloudscraper
from bs4 import BeautifulSoup as bs

scraper = cloudscraper.create_scraper()  # returns a CloudScraper instance
# Or: scraper = cloudscraper.CloudScraper()  # CloudScraper inherits from requests.Session
content = scraper.get("https://www.innvictus.com/medias/Product-es-MXN-1-7760233188917943532.xml?context=bWFzdGVyfHJvb3R8MTM1Mjc3Njh8dGV4dC94bWx8aGRjL2g2My8xMDA1NjEwNDM3ODM5OC54bWx8OTgyNjQ5ODNmMWNiNTNiMGM1MGFlNmU2ZmJlMWU2ZTUxZDBiNDllNzg1ZjM3YTk3MDBmZjM4YTYxZjc1NGVkMA")
bs_content = bs(content.content, "lxml")
result = bs_content.find_all("loc")
url = []
for link in result:
    url.append(link)

Yesterday it was working fine, but today i get that errors

Thank you

Source: Python Questions

LEAVE A COMMENT