Skip to content

Commit

Permalink
Merge pull request #992 from agastya3636/main
Browse files Browse the repository at this point in the history
Added Atcoder module
  • Loading branch information
nikhil25803 authored May 17, 2024
2 parents 253ce2a + daa07a5 commit 80fe831
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 24 deletions.
54 changes: 35 additions & 19 deletions dev-documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ user = github.Users(username="nikhil25803")
| `.star_count()` | Returns the number of stars of a user. |
| `.get_yearly_contributions()` | Returns the number of contributions made in 365 days frame. |
| `.get_repositories()` | Returns the list of repositories of a user. |
| `.get_starred_repos()` | Returns the list of starred repositories of a user. |
| `.pul_requests()` | Returns the number of pull requests opened in a repository. |
| `.get_starred_repos()` | Returns the list of starred repositories of a user. |
| `.pul_requests()` | Returns the number of pull requests opened in a repository. |
| `.get_followers()` | Returns the list of followers of a user. |
| `.get_following_users()` | Returns the list of users followed by a user. |
| `.get_achievements()` | Returns the list of achievements of a user. |
Expand Down Expand Up @@ -712,8 +712,8 @@ Create an instance of `Video` class.
video = Video(video_url="video_url")
```

| Methods | Details |
| --------------- | ------------------------ |
| Methods | Details |
| --------------- | ------------------------- |
| `.getDetails()` | Returns the video details |

## Scrape Channel Details
Expand Down Expand Up @@ -1173,10 +1173,10 @@ user = Codechef(id="username")

```

| Methods | Details |
| --------------- | ------------------------------------------------------------------------- |
| `get_profile()` | Returns name, username, profile_image_link, rating, details etc. |
| `get_contests()`| Returns future_contests , past_contests , skill_tests etc in json format. |
| Methods | Details |
| ---------------- | ------------------------------------------------------------------------- |
| `get_profile()` | Returns name, username, profile_image_link, rating, details etc. |
| `get_contests()` | Returns future_contests , past_contests , skill_tests etc in json format. |

---

Expand Down Expand Up @@ -1656,49 +1656,49 @@ First create an object of class `Dictionary`.
| `.get_word_of_the_day()` | Returns the word of the day. |
| `.word_of_the_day_definition()` | Returns the definition of the word of the day. |

--------

---

#### AmbitionBx
#### AmbitionBx

Create an directory with name ambitonbox
created a python which consist the code for scarping the website
created a python which consist the code for scarping the website

```python
# Example usage
from scrape_up import ambitionBox

num_pages_to_scrape = 2
num_pages_to_scrape = 2

scraper = ambitionBox.Comapiens(num_pages_to_scrape)

scraper.scrape_companies()

```

| Methods | Details |
| --------------- | ----------------------------------------------------------------------------- |
| Methods | Details |
| --------------------- | ----------------------------------------- |
| `.scrape_companies()` | Returns the company name with the rating. |

---

## Geeksforgeeks

First create an object of class `Geeksforgeeks`.

```python
geeksforgeeks = Geeksforgeeks(user="username")
```

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

---

## Wuzzuf

```python
from scrap-up import wuzzuf
from scrap_up import wuzzuf
jobs = wuzzuf.Jobs()
```

Expand All @@ -1708,3 +1708,19 @@ The `Jobs` class provides methods for configuring scraping parameters and fetchi
| --------------- | ---------------------------------------------------------------------------------------- |
| `.filter_job()` | Apply filters such as job title, country, city, and range of years of experience. |
| `.fetch_jobs()` | Fetch job listings from the website based on the applied filters, across multiple pages. |

## Atcoder

First create an object of class `Atcoder`.

```python
from scrap_up import Atcoder
atcoder = Atcoder(user="username")
atcode.get_profile()
```

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

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

__all__ = ["Atcoder"]
79 changes: 79 additions & 0 deletions src/scrape_up/atcoder/atcoder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import json
import requests
from bs4 import BeautifulSoup


class Atcoder:
"""
```
atc = Atcoder(user="chokudai")
atc.get_profile()
```
| Methods | Details |
| ----------------- | ---------------------------------------------------------------------------------- |
| `.get_profile()` | Returns the user data in json format. |
Response
```json
{
"Country/Region": "Japan",
"Birth_Year": "1988",
"Twitter_ID": "@chokudai",
"TopCoder_ID": "chokudai",
"Codeforces_ID": "chokudai",
"Affiliation": "AtCoder Inc. CEO",
"Algorithm_Rank": "44th",
"Algorithm_Rating": "3028",
"Algorithm_Highest_Rating": "3092 ― 6 Dan (+108 to promote)",
"Algorithm_Rated_Matches_": "35",
"Algorithm_Last_Competed": "2023/12/17",
"Heuristic_Rank": "62nd",
"Heuristic_Rating": "2525 (Provisional)",
"Heuristic_Highest_Rating": "2525",
"Heuristic_Rated_Matches_": "8",
"Heuristic_Last_Competed": "2024/04/07"
}
```
"""


def __init__(self, user):
self.user = user

def get_profile(self):
try:
url = f"https://atcoder.jp/users/{self.user}"
headers = {"User-Agent": "scrapeup"}
response = requests.get(url, headers=headers)
soup = BeautifulSoup(response.text, "html.parser")
table = soup.find_all("table", class_="dl-table")
user_details = {}

row = table[0].find_all("tr")
for r in row:
user_details[r.find("th").text.replace(" ", "_")] = (
r.find("td").text.replace("\n", " ").strip()
)

row = table[1].find_all("tr")
for r in row:
user_details["Algorithm_" + r.find("th").text.replace(" ", "_")] = (
r.find("td").text.replace("\n", " ").strip()
)

url = f"https://atcoder.jp/users/{self.user}?contestType=heuristic"
response = requests.get(url, headers=headers)
soup = BeautifulSoup(response.text, "html.parser")
table = soup.find_all("table", class_="dl-table")
row = table[1].find_all("tr")
for r in row:
user_details["Heuristic_" + r.find("th").text.replace(" ", "_")] = (
r.find("td").text.replace("\n", " ").strip()
)
return json.dumps(user_details)
except:
return None


atc = Atcoder(user="chokudai")
print(atc.get_profile())
2 changes: 1 addition & 1 deletion src/scrape_up/espncricinfo/espncricinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ def get_livescores(self):
live_scores.append(match_details)
return live_scores
except:
return live_scores
return live_scores
1 change: 0 additions & 1 deletion src/scrape_up/pinterest/pinterest.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,3 @@ def get_pin_details(self, pin_url):
}
except Exception as e:
return None

1 change: 0 additions & 1 deletion src/test/espncricinfo_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@


class ESPNTest(unittest.TestCase):

def test_connection(self):
instance = Espncricinfo()
self.assertTrue(
Expand Down
4 changes: 2 additions & 2 deletions src/test/pinterest_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_get_today(self):
self.assertIn("image", topic)

def test_get_photo(self):
url = "https://pin.it/1ZhgQA5AG"
url = "https://pin.it/1ZhgQA5AG"
photo = self.pinterest.get_photo(url)
if photo:
self.assertIn("alt", photo)
Expand All @@ -33,7 +33,7 @@ def test_search_pins(self):
self.assertIn("image", pin)

def test_get_pin_details(self):
pin_url = "https://pin.it/1ZhgQA5AG"
pin_url = "https://pin.it/1ZhgQA5AG"
details = self.pinterest.get_pin_details(pin_url)
if details:
self.assertIn("title", details)
Expand Down

0 comments on commit 80fe831

Please sign in to comment.