Skip to content

Commit

Permalink
Merge pull request #938 from GbCderr14/main
Browse files Browse the repository at this point in the history
Fixed scraping function of fetching research topics from academia.
  • Loading branch information
nikhil25803 authored May 14, 2024
2 parents f336697 + 9b006d9 commit 0c09dc8
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dev-documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -1471,7 +1471,7 @@ academia = Academia()

| Method | Details |
| ----------------------------- | --------------------------------------------------------------------- |
| `get_research_topics(letter)` | Fetches and returns research topics starting with the given letter. |
| `get_research_topics()` | Fetches and returns research topics. |
| `get_research_papers(search)` | Fetches and returns research papers related to the given search term. |

---
Expand Down
2 changes: 1 addition & 1 deletion documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ academia = academia.Academia()

| Method | Details |
| ----------------------------- | --------------------------------------------------------------------- |
| `get_research_topics(letter)` | Fetches and returns research topics starting with the given letter. |
| `get_research_topics()` | Fetches and returns research topics. |
| `get_research_papers(search)` | Fetches and returns research papers related to the given search term. |

---
Expand Down
5 changes: 2 additions & 3 deletions src/scrape_up/academia/academia.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self):
"User-Agent": "Mozilla/5.0 (Windows NT 6.3; Win 64 ; x64) Apple WeKit /537.36(KHTML , like Gecko) Chrome/80.0.3987.162 Safari/537.36"
}

def get_research_topics(self, topic="None"):
def get_research_topics(self):
"""
Fetches and returns research topics starting with the given letter.\n
Param `letter`: The letter to filter research topics (default is "None" to get all topics).\n
Expand All @@ -45,8 +45,7 @@ def get_research_topics(self, topic="None"):
```
"""
try:
letter = topic.capitalize()
url = f"https://www.academia.edu/topics/{letter}"
url = f"https://www.academia.edu/topics/"
html_text = requests.get(url, headers=self.headers).text
soup = BeautifulSoup(html_text, "lxml")

Expand Down
2 changes: 1 addition & 1 deletion src/test/academia_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def setUp(self):

def test_get_research_topics(self):
academia = Academia()
result = academia.get_research_topics(topic="Machine Learning")
result = academia.get_research_topics()
self.assertIsNotNone(result)
self.assertIsInstance(result, list)

Expand Down

0 comments on commit 0c09dc8

Please sign in to comment.