Skip to content
Advertisement

How to only scrape link from webpage – Python

My goal is to get each link

My code prints the href/link, however it also prints other junk which i do not want.

I only want the href/

JavaScript

Advertisement

Answer

Because href=True means get those tags with href attribute.There are still Tag. To get the href, you also need to use .get("href").Since there is only one button in each session tag, you could use find instead of find_all,and don’t forget to join the baseURL.Try code below:

JavaScript

Print:

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