Python - Getting all links from a div having a class

前端 未结 4 1384
萌比男神i
萌比男神i 2021-02-03 11:09

I am using BeautifulSoup to get all links of mobile phones from this url http://www.gsmarena.com/samsung-phones-f-9-0-p2.php

My code for the following is :



        
4条回答
  •  自闭症患者
    2021-02-03 11:48

    If you have Python 3, you can use Simon's answer with the following change:

    from urllib.request import urlopen
    from bs4 import BeautifulSoup
    
    text = urlopen(base_url).read()
    

提交回复
热议问题