-
-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into walmart_scraper
- Loading branch information
Showing
23 changed files
with
1,488 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .codewars import Codewars | ||
|
||
__all__ = ["Codewars"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
from bs4 import BeautifulSoup | ||
import json | ||
from scrape_up.config.request_config import RequestConfig, get | ||
|
||
|
||
class Codewars: | ||
""" | ||
Create an instance of the class `GeeksforGeeks` | ||
```py | ||
cwars = Codewars(user="agastya463") | ||
cwars.get_profile() | ||
``` | ||
| Methods | Details | | ||
| ----------------- | ---------------------------------------------------------------------------------- | | ||
| `.get_profile()` | Returns the user data in json format. | | ||
Response: | ||
```js | ||
{ | ||
"Name": "Agastya Kumar Yadav", | ||
"Clan": "Unknown", | ||
"Member Since": "May 2024", | ||
"Last Seen": "May 2024", | ||
"Profiles": "", | ||
"Following": "0", | ||
"Followers": "0", | ||
"Allies": "0", | ||
"Rank": "8 kyu", | ||
"Honor": "3", | ||
"Total Completed Kata": "1", | ||
"Total Languages Trained": "1", | ||
"Highest Trained": "C++ (8 kyu)", | ||
"Most Recent": "C++", | ||
"Comments": "0 (0 replies)", | ||
"Collections": "0", | ||
"Kumite": "0", | ||
"Translations": "0 (0 approved)" | ||
} | ||
``` | ||
""" | ||
|
||
def __init__(self, user: str, *, config: RequestConfig = RequestConfig()): | ||
self.user = user | ||
headers = {"User-Agent": "scrapeup"} | ||
self.config = config | ||
if self.config.headers == {}: | ||
self.config.set_headers(headers) | ||
|
||
def get_profile(self): | ||
try: | ||
url = f"https://www.codewars.com/users/{self.user}" | ||
response = get(url, self.config) | ||
soup = BeautifulSoup(response.text, "html.parser") | ||
d = soup.find_all("div", class_="stat") | ||
data = {} | ||
for i in d: | ||
k = i.text.split(":") | ||
data[k[0]] = k[1] | ||
return json.dumps(data) | ||
except Exception: | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from weather import Indiatodayweather | ||
|
||
__all__ = ["Indiatodayweather"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import requests | ||
import datetime as dt | ||
from bs4 import BeautifulSoup | ||
|
||
|
||
class Indiatodayweather: | ||
""" | ||
A class to scrape weather data from Indian today | ||
Create an instance of `Indiatodayweather` class | ||
```python | ||
weather=Indiatodayweather("Mumbai") | ||
``` | ||
| Method | Details | | ||
| --------------------------- | ------------------------------------------------------------------------ | | ||
|`info_about_weather()` | return the temperature, wind speed, description(windy, cloudy, clear) and humidity of the place. | | | ||
--- | ||
""" | ||
|
||
def __init__(self, place): | ||
try: | ||
self.place = place | ||
url = ( | ||
"https://www.indiatoday.in/weather/" | ||
+ self.place | ||
+ "-weather-forecast-today" | ||
) | ||
response = requests.get(url, headers={"User-Agent": "XY"}) | ||
self.soup = BeautifulSoup(response.content, "lxml") | ||
|
||
except: | ||
return None | ||
|
||
def info_about_weather(self): | ||
try: | ||
temp = self.soup.find("div", class_="wtr_tmp_rhs").text | ||
humid = self.soup.find("span", class_="wtr_crd_ttl").text + " %" | ||
description = self.soup.find("span", class_="wtr_tmp_txt").text | ||
speed = ( | ||
self.soup.find("div", class_="wtr_wid_sec crd_three") | ||
.find("span", class_="wtr_crd_ttl") | ||
.text | ||
) + " km/h" | ||
|
||
weather_info = { | ||
"temperature": temp, | ||
"humidity": humid, | ||
"description": description, | ||
"wind_speed": speed, | ||
} | ||
return weather_info | ||
except: | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .lastfm import Lastfm | ||
|
||
__all__ = ["Lastfm"] |
Oops, something went wrong.