Skip to content

Commit

Permalink
Merge branch 'main' into walmart_scraper
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhil25803 authored Jun 2, 2024
2 parents 8be160f + 67b42dd commit b5b235f
Show file tree
Hide file tree
Showing 23 changed files with 1,488 additions and 88 deletions.
101 changes: 99 additions & 2 deletions dev-documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ from scrape_up import github
user = github.Users(username="nikhil25803")

# Call the followers function - it will return the number of followers
user.followers()
print(user.followers())
```

---
Expand Down Expand Up @@ -1680,6 +1680,48 @@ First create an object of class `Dictionary`.

---

## SystemRequirementsLab

### Scrape Titles

Create an instance of `FindTitles` class.

```python
titles = sysreqlab.FindTitles(search_term="Call of Duty", search_alphabet="c")
```

| Methods | Details |
| -------------------------------- | --------------------------------------------------------------------- |
| `.find_titles(number_of_titles)` | Returns the list of titles based on the search term, search alphabet. |

### Scrape System Requirements

Create an instance of `Requirements` class.

```python
requirements = sysreqlab.Requirements(search_term="Cyberpunk 2077", search_alphabet="c")
```

| Methods | Details |
| ----------------------------- | ------------------------------------------------------- |
| `.minimum_graphics()` | Returns the minimum graphics required for the game. |
| `.minimum_cpu()` | Returns the minimum CPU required for the game. |
| `.minimum_ram()` | Returns the minimum RAM required for the game. |
| `.minimum_os()` | Returns the minimum OS required for the game. |
| `.minimum_storage()` | Returns the minimum storage required for the game. |
| `.minimum_vram()` | Returns the minimum VRAM required for the game. |
| `.recommended_graphics()` | Returns the recommended graphics required for the game. |
| `.recommended_cpu()` | Returns the recommended CPU required for the game. |
| `.recommended_ram()` | Returns the recommended RAM required for the game. |
| `.recommended_os()` | Returns the recommended OS required for the game. |
| `.recommended_storage()` | Returns the recommended storage required for the game. |
| `.recommended_vram()` | Returns the recommended VRAM required for the game. |
| `.minimum_requirements()` | Returns the minimum requirements for the game. |
| `.recommended_requirements()` | Returns the recommended requirements for the game. |

-----


#### AmbitionBx

Create an directory with name ambitonbox
Expand Down Expand Up @@ -1873,6 +1915,23 @@ data = Yellowpages("restaurtant", "New York")

---

### Indiatodayweather

```py
from scrape_up import Indiatodayweather
```
Create an instance of `Indiatodayweather` class

```python
weather=Indiatodayweather("Mumbai")
```

| Method | Details |
| --------------------------- | ------------------------------------------------------------------------ |
|`info_about_weather()` | return the temperature, wind speed ,description
and humidity of the place. |
---

## Bayt

```python
Expand Down Expand Up @@ -1924,6 +1983,8 @@ print(letterboxd_user.get_followers_count())

Note: `n` is an integer value which is optional and can be used to limit the number of results returned by the methods.

-----

# Walmart Product Scraper
```python
from scrape_up import WalmartProduct
Expand All @@ -1937,4 +1998,40 @@ product = WalmartProduct("example-product-name")
| `get_product_image()` | Get the URL of the product image from the product page. |
| `customer_review()` | Get customer reviews of the product from the product page. |

---
---

#### Lastfm

```python
from scrape_up.lastfm import Lastfm

lastfm_user = Lastfm("arpy8")
print(lastfm_user.get_followers())
```

Class - `Lastfm`

| Methods | Details |
| --------------------------- | ---------------------------------------------------------------------------------------------------- |
| `.user_stats()` | Returns the numbers of scrobbles, artists and loved tracks. |
| `.recent_tracks()` | Returns a dictionary containing the latest tracks scrobbled by the user. |
| `.top_tracks()` | Returns a dictionary containing the top tracks of the user. |
| `.top_albums()` | Returns a dictionary containing the top albums of the user. |
| `.top_artists()` | Returns a dictionary containing the top artists of the user. |
| `.get_following()` | Returns the total number of users followed by the user. |
| `.get_followers()` | Returns the total number of followers of the user. |

Note: usernames are case sensitive.


#### CodeWars
```python
cwars = Codewars(user="agastya463")
cwars.get_profile()
```

| Methods | Details |
| ----------------- | ---------------------------------------------------------------------------------- |
| `.get_profile()` | Returns the user data in json format. |

---
2 changes: 1 addition & 1 deletion documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ from scrape_up import github
user = github.Users(username="Suhani2")

# Call the followers function - it will return the number of followers
per user.followers()
print(user.followers())
```

---
Expand Down
3 changes: 3 additions & 0 deletions src/scrape_up/codewars/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .codewars import Codewars

__all__ = ["Codewars"]
63 changes: 63 additions & 0 deletions src/scrape_up/codewars/codewars.py
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
3 changes: 3 additions & 0 deletions src/scrape_up/indiatodayweather/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from weather import Indiatodayweather

__all__ = ["Indiatodayweather"]
56 changes: 56 additions & 0 deletions src/scrape_up/indiatodayweather/weather.py
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
3 changes: 3 additions & 0 deletions src/scrape_up/lastfm/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .lastfm import Lastfm

__all__ = ["Lastfm"]
Loading

0 comments on commit b5b235f

Please sign in to comment.