List index out of range error
Opened this issue · 1 comments
JuliavOosten commented
Hi! Thanks for your code, it is exactly what I was looking for! However, when using it I get the following error:
Please enter the keyword (Dutch[Language])
Please enter the number of results 10000
Traceback (most recent call last):
File "Scrape_PubMed.py", line 201, in <module>
article = get_bibliography(soup)
File "Scrape_PubMed.py", line 62, in get_bibliography
initial = authorlist.find_all('initials')[i].text
IndexError: list index out of range
How do I fix this? I know there are 20000+ results for that keyword so I don't really see what's off here...
Arefeh-V commented
Hi! Thanks for your code, it is exactly what I was looking for! However, when using it I get the following error:
Please enter the keyword (Dutch[Language]) Please enter the number of results 10000 Traceback (most recent call last): File "Scrape_PubMed.py", line 201, in <module> article = get_bibliography(soup) File "Scrape_PubMed.py", line 62, in get_bibliography initial = authorlist.find_all('initials')[i].text IndexError: list index out of range
How do I fix this? I know there are 20000+ results for that keyword so I don't really see what's off here...
hi, I hope it is not too late but I had the same problem. It's because some authors don't have 'initials', so in the loop for the next author it will throw 'out of range' error. I solved it by simply checking the existence of 'initials'