<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: poojadathpk</title>
    <description>The latest articles on DEV Community by poojadathpk (@poojadathpk).</description>
    <link>https://dev.to/poojadathpk</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4048931%2F62c96c5c-9738-4e05-be7c-f31bb6e9424f.png</url>
      <title>DEV Community: poojadathpk</title>
      <link>https://dev.to/poojadathpk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/poojadathpk"/>
    <language>en</language>
    <item>
      <title>How to Scrape Weather Data in 5 Lines of Python</title>
      <dc:creator>poojadathpk</dc:creator>
      <pubDate>Wed, 29 Jul 2026 17:59:35 +0000</pubDate>
      <link>https://dev.to/poojadathpk/how-to-scrape-weather-data-in-5-lines-of-python-40eh</link>
      <guid>https://dev.to/poojadathpk/how-to-scrape-weather-data-in-5-lines-of-python-40eh</guid>
      <description>&lt;p&gt;Web scraping allows developers to extract data from websites automatically. Whether you're building a price tracker or an automated news aggregator, extracting HTML elements is a core skill.&lt;/p&gt;

&lt;p&gt;In this quick tutorial, you'll learn how to scrape live weather information using Python's &lt;code&gt;requests&lt;/code&gt; and &lt;code&gt;BeautifulSoup&lt;/code&gt; libraries.&lt;/p&gt;




&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;p&gt;Before starting, make sure you have Python installed, then install the required libraries via your terminal:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
bash
pip install requests beautifulsoup4
import requests
from bs4 import BeautifulSoup

Step 1: Fetch the HTML Page
First, import the required modules and send an HTTP request to fetch the web page HTML:

url = "[https://wttr.in/London](https://wttr.in/London)"
response = requests.get(url)

print(f"Status Code: {response.status_code}")

Step 2: Parse and Extract Data
Now, pass the page content into BeautifulSoup to locate and clean up the weather report text:

soup = BeautifulSoup(response.text, 'html.parser')

# Extract plain text content from the output
weather_data = soup.get_text()

# Print the top lines of the report
print("\n--- Current Weather Output ---")
print("\n".join(weather_data.splitlines()[:7]))

### Future Improvements

* **Save to CSV:** Export the scraped weather data into a CSV file for tracking trends over time.
* **Automate via Cron Job:** Schedule the script to run automatically every morning at 8 AM.
* **Send Email Alerts:** Integrate the `smtplib` library to email yourself a daily weather report.

Conclusion
With just a few lines of Python, you've fetched web content and extracted useful data! From here, you can schedule this script to run daily or save the scraped data to a JSON or CSV file.

![ ](https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/kkkvii2q5eybow1vh1zh.png)



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>python</category>
      <category>webdev</category>
      <category>ai</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
