_extract_post_id uses the class _5pcq to get the postId. This sometimes fails when there is a long list of items with that class, some of which have an effectively empty href tag. Propose a fix where we check if the href tag contains a URL (beginning with '/') before extracting.
Sample list of prints from item.find_all(class_="_5pcq") below. The last item on the list has '#' in the href field. This causes the resultant post_id to be '#'.
To replicate:
python scraper.py -p TheStraitsTimes -l 1
_extract_post_id
uses the class_5pcq
to get the postId. This sometimes fails when there is a long list of items with that class, some of which have an effectively emptyhref
tag. Propose a fix where we check if thehref
tag contains a URL (beginning with '/') before extracting.Sample list of prints from
item.find_all(class_="_5pcq")
below. The last item on the list has '#' in thehref
field. This causes the resultantpost_id
to be '#'.To replicate:
python scraper.py -p TheStraitsTimes -l 1