geekcomputers / geekcomputers/Python

add a stackoverflow web scrapper

Open
#761 0 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.