Scraping text in h3 and div tags using beautifulSoup, Python

后端 未结 3 840
忘掉有多难
忘掉有多难 2020-12-31 20:51

I have no experience with python, BeautifulSoup, Selenium etc. but I\'m eager to scrape data from a website and store as a csv file. A single sample of data I need is coded

3条回答
  •  生来不讨喜
    2020-12-31 21:23

    Try this:

    import urllib2
    from bs4 import BeautifulSoup
    import requests
    import csv
    
    MAX = 2
    
    '''with open("lg.csv", "a") as f:
      w=csv.writer(f)'''
    ##for i in range(1,MAX+1)
    url="http://www.example_site.com"
    
    page=requests.get(url)
    soup = BeautifulSoup(page,"html.parser")
    
    print(soup.text)
    

提交回复
热议问题