Skip to content
Advertisement

How can I fix my python code about web scraper based on the beautifulsoup?

I’m a very beginner of Python.

I tried to make some web scraper (especially PubMed).

Using my code, I want to print the result which has not only the title of papers, but doi (or any accession links of the paper) like below.

Title: ABCD ABCD ABCD ABCD [http:// ~~~~]

Title: ABCD ABCD ABCD ABCD [http:// ~~~~]

Title: ABCD ABCD ABCD ABCD [http:// ~~~~]

….

But, in the final stage,

I can not show the title and links, simultaneously.

When I print each factors, respectively, it works.

Also, I don’t know exactly how to use ‘for’.

I really appreciate for your consideration of my question.

Thanks.

JavaScript

Advertisement

Answer

Change the selectors. Half of your code is correct

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement