Vangelis Katsikaros

Question 1

Could you help me write a basic web scraper in python?

import requests
from bs4 import BeautifulSoup

url = 'https://example-blog.com'
response = requests.get(url)

if response.status_code == 200:
    soup = BeautifulSoup(response.content, 'html.parser')
    titles = soup.find_all('h2')

    for title in titles:
        print(title.get_text())
else:
    print('Failed to retrieve the webpage. Status code:', response.status_code)

Oh that’s nice! Let’s copy paste this in Google Colab, and see if there are any syntax errors.

Could you guess what we need to change in order to scrape the site we want (https://vkatsikaros.github.io/dataharvest24-www.github.io/)?

If not, we can try and ask the LLM!

Index question 2 ⇨