Entiende el código de forma correcta previamente a utilizarlo a tu trabajo si ttienes algo que aportar puedes dejarlo en la sección de comentarios.
Ejemplo 1: raspado web de python
import requests
from bs4 import BeautifulSoup
URL ='https://www.monster.com/jobs/search/?q=Software-Developer&where=Australia'
page = requests.get(URL)
soup = BeautifulSoup(page.content, 'html.parser')
Ejemplo 2: beautifulsoup python
import bs4 as bs
import urllib.request
source= urllib.request.urlopen('https://pythonprogramming.net/parsememcparseface/').read()
Ejemplo 3: web scraping python
import scrapy
from ..items import SampletestItem #items class
class QuoteTestSpider(scrapy.Spider):
name ='quote_test'
start_urls =['https://quotes.toscrape.com/']
def parse(self, response):
items = SampletestItem()#items class
quotes = response.css("div.quote")forquotein quotes:
items['title']= quote.css("span.text::text").get()
items['author']= quote.css(".author::text").get()
items['tags']= quote.css(".tags .tag::text").getall()
yield items
next_page = response.css(".next a::attr(href)").get()if next_page is not None:
next_url = response.urljoin(next_page)
yield scrapy.Request(next_url, callback=self.parse)
Ejemplo 4: BeautifulSoup – lista de extracción de html
from bs4 import BeautifulSoup
# Simple HTML
SIMPLE_HTML ='''<html><head></head><body><h1>This is a title</h1><p class="subtitle">Lorem ipsum dolor sit amet.</p><p>Here's another p without a class
- Sarah
- Mary
- Charlotte
- Carl