Answer the question
In order to leave comments, you need to log in
Why does the error occur: 'NoneType' object has no attribute 'group'?
Good afternoon!
Error intermittently:
Traceback (most recent call last):
File "/home/oksana/Desktop/main/main.py", line 14, in
first_link = re.search(r'(?<=par_picture":"\ \/\\/).*?(?=")', markup).group(0)
AttributeError: 'NoneType' object has no attribute 'group'
res = requests.get(url)
src = res.content
soup = BeautifulSoup(src, 'lxml')
markup = soup.prettify()
first_link = re.search(r'(?<=par_picture":"\\/\\/).*?(?=")', markup).group(0)
print(first_link)
first_number = re.search(r'(?<=480\\/).*?(?=.jpg)', first_link).group(0)
print(first_number)
numbers = re.findall(r'\bdata-image-id="\s*([^"]+)', markup)
print(numbers)
Answer the question
In order to leave comments, you need to log in
The resource you requested does not always return the expected data.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question