From c372e98e72358d79ae292e0f43be051636254565 Mon Sep 17 00:00:00 2001 From: Nikhil Raj Date: Fri, 17 May 2024 20:31:14 +0530 Subject: [PATCH] Check --- dev-documentation.md | 52 ++++----- documentation.md | 124 +++++++++------------ src/scrape_up/espncricinfo/espncricinfo.py | 2 +- src/scrape_up/fide/__init__.py | 2 +- src/scrape_up/fide/fide.py | 24 ++-- src/scrape_up/pinterest/pinterest.py | 1 - src/test/espncricinfo_test.py | 1 - src/test/fide_test.py | 6 +- src/test/pinterest_test.py | 4 +- 9 files changed, 98 insertions(+), 118 deletions(-) diff --git a/dev-documentation.md b/dev-documentation.md index 181b1a22..18e50d3d 100644 --- a/dev-documentation.md +++ b/dev-documentation.md @@ -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. | @@ -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 @@ -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. | --- @@ -1427,14 +1427,14 @@ Create an instance of `FIDE` class. obj = fide.FIDE() ``` -| Methods | Details | -| ------------------------- | -------------------------------------------------- | -| `.get_events()` | Returns all the major chess events of 2024. | -| `.get_open_ratings()` | Returns a list of top 100 open category players. | -| `.get_women_ratings()` | Returns a list of top 100 women category players. | -| `.get_juniors_ratings()` | Returns a list of top 100 juniors category players.| -| `.get_girls_ratings()` | Returns a list of top 100 girls category players. | -| `.get_news()` | Returns a list of top chess/fide news. | +| Methods | Details | +| ------------------------ | --------------------------------------------------- | +| `.get_events()` | Returns all the major chess events of 2024. | +| `.get_open_ratings()` | Returns a list of top 100 open category players. | +| `.get_women_ratings()` | Returns a list of top 100 women category players. | +| `.get_juniors_ratings()` | Returns a list of top 100 juniors category players. | +| `.get_girls_ratings()` | Returns a list of top 100 girls category players. | +| `.get_news()` | Returns a list of top chess/fide news. | # Magic Bricks @@ -1677,19 +1677,18 @@ 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) @@ -1697,8 +1696,8 @@ scraper.scrape_companies() ``` -| Methods | Details | -| --------------- | ----------------------------------------------------------------------------- | +| Methods | Details | +| --------------------- | ----------------------------------------- | | `.scrape_companies()` | Returns the company name with the rating. | --- @@ -1706,13 +1705,14 @@ scraper.scrape_companies() ## 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. | --- diff --git a/documentation.md b/documentation.md index f006014d..342172ac 100644 --- a/documentation.md +++ b/documentation.md @@ -281,10 +281,10 @@ Create an object of class `Contest`. hackerank = hackerrank.Contest() ``` -| Methods | Details | -| --------------------- | ------------------------------------------------------------------- | -| `active_contests()` | Returns information on active contests like title, status, and link.| -| `archived_contests()` | Returns information regarding archived contests. | +| Methods | Details | +| --------------------- | -------------------------------------------------------------------- | +| `active_contests()` | Returns information on active contests like title, status, and link. | +| `archived_contests()` | Returns information regarding archived contests. | --- @@ -300,12 +300,12 @@ Create an instance of `Hashnode` class. blogs = hashnode.Hashnode() ``` -| Methods | Details | -| ----------------- | ------------------------------------------------------------------------------------------------------ | -| `.get_feed()` | Returns the blogs with title, descriptions, author, read time, like and comment count, date, and link. | -| `.get_featured()` | Returns the featured blogs with title, descriptions, author, like and comment count, date, and link. | -| `.get_recent()` | Returns the recent blogs with title, descriptions, author, like and comment count, date, and link. | -| `.search(topic)` | Returns the blogs with title, descriptions, author, like and comment count, date, and link for a topic.| +| Methods | Details | +| ----------------- | ------------------------------------------------------------------------------------------------------- | +| `.get_feed()` | Returns the blogs with title, descriptions, author, read time, like and comment count, date, and link. | +| `.get_featured()` | Returns the featured blogs with title, descriptions, author, like and comment count, date, and link. | +| `.get_recent()` | Returns the recent blogs with title, descriptions, author, like and comment count, date, and link. | +| `.search(topic)` | Returns the blogs with title, descriptions, author, like and comment count, date, and link for a topic. | --- @@ -361,14 +361,14 @@ Create an instance of `Questions` class. questions = askubuntu.Questions("topic") ``` -| Methods | Details | -| --------------------------- | ---------------------------------------------------------------------------------------------------- | -| `.getNewQuestions()` | Returns the new questions, views, votes, answer counts, and descriptions in JSON format. | -| `.getActiveQuestions()` | Returns the active questions, views, votes, answer counts, and descriptions in JSON format. | -| `.getUnansweredQuestions()` | Returns the unanswered questions, views, votes, answer counts, and descriptions in JSON format. | -| `.getBountiedQuestions()` | Returns the bountied questions, views, votes, answer counts, and descriptions in JSON format. | -| `.getFrequentQuestions()` | Returns the frequently asked questions, views, votes, answer counts, and descriptions in JSON format.| -| `.getHighScoredQuestions()` | Returns the most voted questions, views, votes, answer counts, and descriptions in JSON format. | +| Methods | Details | +| --------------------------- | ----------------------------------------------------------------------------------------------------- | +| `.getNewQuestions()` | Returns the new questions, views, votes, answer counts, and descriptions in JSON format. | +| `.getActiveQuestions()` | Returns the active questions, views, votes, answer counts, and descriptions in JSON format. | +| `.getUnansweredQuestions()` | Returns the unanswered questions, views, votes, answer counts, and descriptions in JSON format. | +| `.getBountiedQuestions()` | Returns the bountied questions, views, votes, answer counts, and descriptions in JSON format. | +| `.getFrequentQuestions()` | Returns the frequently asked questions, views, votes, answer counts, and descriptions in JSON format. | +| `.getHighScoredQuestions()` | Returns the most voted questions, views, votes, answer counts, and descriptions in JSON format. | --- @@ -421,13 +421,13 @@ Create an instance of the `CovidInfo` class. response = covidinfo.CovidInfo() ``` -| Methods | Details | -| -------------------- | --------------------------------------------------------------- | -| `.covid_data()` | Returns the list of all covid data scraped from the website. | -| `.total_cases()` | Returns the count of total covid cases all over the world. | -| `.total_deaths()` | Returns the count of deaths covid cases all over the world. | -| `.total_recovered()` | Returns the count of recovered covid cases all over the world. | -| `.latest_news()` | Return the latest news of the day. | +| Methods | Details | +| -------------------- | -------------------------------------------------------------- | +| `.covid_data()` | Returns the list of all covid data scraped from the website. | +| `.total_cases()` | Returns the count of total covid cases all over the world. | +| `.total_deaths()` | Returns the count of deaths covid cases all over the world. | +| `.total_recovered()` | Returns the count of recovered covid cases all over the world. | +| `.latest_news()` | Return the latest news of the day. | --- @@ -473,15 +473,15 @@ Create an instance of `Dribbble` class. shots = dribbble.Dribbble() ``` -| Methods | Details | -| --------------------- | ------------------------------------------------------------------------------------------------------------------------------- | -| `.get_shots()` | Returns the latest shots along with their title, designer, designer URL, like and view count, and link. | -| `.search(topic)` | Returns the latest shots along with their title, designer, designer URL, like and view count, and link for the searched topic. | -| `.get_animation()` | Returns the latest animation along with their title, designer, designer URL, like and view count, and link. | -| `.get_branding()` | Returns the latest branding along with their title, designer, designer URL, like and view count, and link. | -| `.get_illustration()` | Returns the latest illustration along with their title, designer, designer URL, like and view count, and link. | -| `.get_mobile()` | Returns the latest mobile shots along with their title, designer, designer URL, like and view count, and link. | -| `.get_webdesign()` | Returns the latest web-design shots along with their title, designer, designer URL, like and view count, and link. | +| Methods | Details | +| --------------------- | ------------------------------------------------------------------------------------------------------------------------------ | +| `.get_shots()` | Returns the latest shots along with their title, designer, designer URL, like and view count, and link. | +| `.search(topic)` | Returns the latest shots along with their title, designer, designer URL, like and view count, and link for the searched topic. | +| `.get_animation()` | Returns the latest animation along with their title, designer, designer URL, like and view count, and link. | +| `.get_branding()` | Returns the latest branding along with their title, designer, designer URL, like and view count, and link. | +| `.get_illustration()` | Returns the latest illustration along with their title, designer, designer URL, like and view count, and link. | +| `.get_mobile()` | Returns the latest mobile shots along with their title, designer, designer URL, like and view count, and link. | +| `.get_webdesign()` | Returns the latest web-design shots along with their title, designer, designer URL, like and view count, and link. | --- @@ -528,29 +528,6 @@ espn = espn.ESPN() --- -### FIDE - -```python -from scrape_up import fide -``` - -Create an instance of `FIDE` class. - -```python -obj = fide.FIDE() -``` - -| Methods | Details | -| ------------------------- | -------------------------------------------------- | -| `.get_events()` | Returns all the major chess events of 2024. | -| `.get_open_ratings()` | Returns a list of top 100 open category players. | -| `.get_women_ratings()` | Returns a list of top 100 women category players. | -| `.get_juniors_ratings()` | Returns a list of top 100 juniors category players.| -| `.get_girls_ratings()` | Returns a list of top 100 girls category players. | -| `.get_news()` | Returns a list of top chess/fide news. | - ---- - ### eBay ```py @@ -631,9 +608,9 @@ Create an instance of `FlipkartLaptops` class. item = flipkart.FlipkartLaptops() ``` -| Methods | Details | -| ------------ | ---------------------------------------- | -| `.laptops()` | Returns the list of laptops with details.| +| Methods | Details | +| ------------ | ----------------------------------------- | +| `.laptops()` | Returns the list of laptops with details. | --- @@ -649,10 +626,10 @@ Create an instance of `Flyrobu` class. flyrobu = flyrobu.Flyrobu() ``` -| Methods | Details | -| ------------------------------------ | --------------------------------------------------------------------------------------------------------------- | -| `.search(keyword)` | Returns the json data of all the details related to search by informing about the total amount of items found. | -| `.get_product_details(product_name)` | Returns the json data of the product details based on the given `product_name`. | +| Methods | Details | +| ------------------------------------ | -------------------------------------------------------------------------------------------------------------- | +| `.search(keyword)` | Returns the json data of all the details related to search by informing about the total amount of items found. | +| `.get_product_details(product_name)` | Returns the json data of the product details based on the given `product_name`. | --- @@ -729,9 +706,9 @@ Create an instance of `Celeb` class. celeb = imdb.Celeb() ``` -| Methods | Details | -| --------------- | ------------------------------------------------------ | -| `.top_celebs()` | Returns the name, roles, and famous movie of the celeb.| +| Methods | Details | +| --------------- | ------------------------------------------------------- | +| `.top_celebs()` | Returns the name, roles, and famous movie of the celeb. | #### IMDB - Indian Movies @@ -741,9 +718,9 @@ Create an instance of `IndianMovies` class. indianmovies = imdb.IndianMovies() ``` -| Methods | Details | -| ---------------------- | --------------------------------------------- | -| `.top_indian_movies()` | Returns the current list of top Indian movies.| +| Methods | Details | +| ---------------------- | ---------------------------------------------- | +| `.top_indian_movies()` | Returns the current list of top Indian movies. | #### IMDB - Box Office @@ -753,7 +730,6 @@ Create an instance of `BoxOffice` class. boxoffice = imdb.BoxOffice() ``` -| Methods | Details | -| --------------- | ------------------------------------------------------------------------------ | -| `.top_movies()` | Returns the top box office movies, weekend and total gross, and weeks released.| - +| Methods | Details | +| --------------- | ------------------------------------------------------------------------------- | +| `.top_movies()` | Returns the top box office movies, weekend and total gross, and weeks released. | diff --git a/src/scrape_up/espncricinfo/espncricinfo.py b/src/scrape_up/espncricinfo/espncricinfo.py index 982883a7..688575dc 100644 --- a/src/scrape_up/espncricinfo/espncricinfo.py +++ b/src/scrape_up/espncricinfo/espncricinfo.py @@ -100,4 +100,4 @@ def get_livescores(self): live_scores.append(match_details) return live_scores except: - return live_scores \ No newline at end of file + return live_scores diff --git a/src/scrape_up/fide/__init__.py b/src/scrape_up/fide/__init__.py index 9316d943..4ca501cd 100644 --- a/src/scrape_up/fide/__init__.py +++ b/src/scrape_up/fide/__init__.py @@ -1,3 +1,3 @@ from .fide import FIDE -__all__ = ["FIDE"] \ No newline at end of file +__all__ = ["FIDE"] diff --git a/src/scrape_up/fide/fide.py b/src/scrape_up/fide/fide.py index acf6f131..c57e3fc2 100644 --- a/src/scrape_up/fide/fide.py +++ b/src/scrape_up/fide/fide.py @@ -1,6 +1,7 @@ import requests from bs4 import BeautifulSoup + class FIDE: """ Create an instance of `FIDE` class. @@ -16,6 +17,7 @@ class FIDE: | `.get_girls_ratings()` | Returns a list of top 100 girls category players. | | `.get_news()` | Returns a list of top chess/fide news. | """ + def __init__(self): self.session = requests.Session() self.BASE_URL = "" @@ -28,11 +30,15 @@ def get_events(self): if res.status_code != 200: return [{"error": "Unable to fetch data from ESPN"}] soup = BeautifulSoup(res.text, "html.parser") - event_domains = soup.find_all("div", attrs={"class": "block-calendar-table-one no-padding col-12"}) + event_domains = soup.find_all( + "div", attrs={"class": "block-calendar-table-one no-padding col-12"} + ) for event_domain in event_domains: table_div = event_domain.find("div", attrs={"class": "ant-table-body"}) events_table = table_div.find("table") - events_table_body = events_table.find("tbody", attrs={"class": "ant-table-tbody"}) + events_table_body = events_table.find( + "tbody", attrs={"class": "ant-table-tbody"} + ) table_rows = events_table_body.find_all("tr") for event in table_rows: try: @@ -45,7 +51,7 @@ def get_events(self): "name": name, "place": place, "start": start, - "end": end + "end": end, } events.append(event) except: @@ -170,19 +176,17 @@ def get_news(self): if res.status_code != 200: return [{"error": "Unable to fetch data from ESPN"}] soup = BeautifulSoup(res.text, "html.parser") - articles_div = soup.find("div", attrs={"class": "wppm wppm-grid s1 columns-3"}) + articles_div = soup.find( + "div", attrs={"class": "wppm wppm-grid s1 columns-3"} + ) articles = articles_div.find_all("article") for article in articles: headline = article.find("div", attrs={"class": "entry-content"}).text date = article.find("aside", attrs={"class": "meta-row row-3"}).text post_url_div = article.find("div", attrs={"class": "post-img"}) url = post_url_div.find("a") - news_details = { - "headline": headline, - "date": date, - "url": url['href'] - } + news_details = {"headline": headline, "date": date, "url": url["href"]} news.append(news_details) return news except: - return news \ No newline at end of file + return news diff --git a/src/scrape_up/pinterest/pinterest.py b/src/scrape_up/pinterest/pinterest.py index b54a309e..14ae7c64 100644 --- a/src/scrape_up/pinterest/pinterest.py +++ b/src/scrape_up/pinterest/pinterest.py @@ -135,4 +135,3 @@ def get_pin_details(self, pin_url): } except Exception as e: return None - diff --git a/src/test/espncricinfo_test.py b/src/test/espncricinfo_test.py index 54ada955..701778dd 100644 --- a/src/test/espncricinfo_test.py +++ b/src/test/espncricinfo_test.py @@ -3,7 +3,6 @@ class ESPNTest(unittest.TestCase): - def test_connection(self): instance = Espncricinfo() self.assertTrue( diff --git a/src/test/fide_test.py b/src/test/fide_test.py index 5654aaf2..079d59df 100644 --- a/src/test/fide_test.py +++ b/src/test/fide_test.py @@ -61,6 +61,7 @@ def test_get_juniors_ratings(self): list, "FIDE:get_juniors_ratings - invalid response", ) + def test_get_girls_ratings(self): instance = FIDE() method_response = instance.get_girls_ratings() @@ -81,5 +82,6 @@ def test_get_news(self): "FIDE:get_news - invalid response", ) - if __name__ == "__main__": - unittest.main() \ No newline at end of file + +if __name__ == "__main__": + unittest.main() diff --git a/src/test/pinterest_test.py b/src/test/pinterest_test.py index 476a3df9..68778858 100644 --- a/src/test/pinterest_test.py +++ b/src/test/pinterest_test.py @@ -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) @@ -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)