geekcomputers / geekcomputers/Python
add a stackoverflow web scrapper
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 35.4k
- Forks
- 12.9k
- Avg merge
- 2h 37m
- Merged PRs (30d)
- 1
Description
Here's the source code of a web scrapper, Made to extract useful questions & answers in stackoverflow
``
import requests
from bs4 import BeautifulSoup
question = input('Type a question : ')
words = question.split(' ')
url = 'https://stackoverflow.com/search?q='+'+'.join(words)
page = requests.get(url)
soup = BeautifulSoup(page.content, 'html.parser')
items = soup.find_all('a',class_='question-hyperlink')
mylist = []
for item in items :
if item['href'].startswith('/questions/'):
mylist.append(item['href'])
link = 'https://stackoverflow.com'+mylist[0]
try:
page = requests.get(link)
soup = BeautifulSoup(page.content, 'html.parser')
items = soup.find_all('div', class_='post-text')
mylist = []
for item in items:
mylist.append(item)
print(mylist[1].text)
except:
print('No fu-----g clue!')
``
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue supplies a Python command-line entry point using requests and BeautifulSoup to search Stack Overflow and print an answer. Start by locating where standalone Python examples belong in the repository, then run the supplied script with a sample question. Done means the scraper is included in the expected location and its intended search-and-display behavior works.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, web-dev
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100