KeyError: 'data-ad-id'
johnstamos999 opened this issue · 2 comments
Hello,
Great scraper! I have been using it for over a year. Thanks for your work on this.
I had the soup issue that other people have already mentioned. I pulled the fixed code today and tried out....now I am getting this error:
[Okay] Ad database succesfully loaded.
Traceback (most recent call last):
[Okay] Ad database succesfully loaded.
Traceback (most recent call last):
File "/home/brain1/kijiji/kijiji2.py", line 257, in
main()
File "/home/brain1/kijiji/kijiji2.py", line 254, in main
scrape(url_to_scrape, old_ad_dict, exclude_list, filename, skip_flag)
File "/home/brain1/kijiji/kijiji2.py", line 185, in scrape
third_party_ad_ids.append(ad['data-ad-id'])
File "/home/brain1/.local/lib/python3.5/site-packages/bs4/element.py", line 1011, in getitem
return self.attrs[key]
KeyError: 'data-ad-id'
My local element.py file has not changed in a year:
brain1@tunnel:~/.local/lib/python3.5/site-packages/bs4$ ls -al element.py
-rw-rw-r-- 1 brain1 brain1 68798 Jun 30 2018 element.py
Any ideas?
It seems Kijiji has slightly changed the class names used in their HTML which is causing this error.
I am currently working on a reformatted/cleaner version of the scraper in the Update-3 branch. I believe the issue is fixed in that branch if you want to use it, however; the usage of the scraper is slightly different and you will have to put the URLs you want to scrape into the config.py file.
I will also fix the code in master when I get a chance and will update this issue once it's done.
Fixed in #12