Skip to main content

A faster way to surf the net - Made in Python

So one day in class I was surfing the net and grew tired of waiting on all of the images and widgets to load. I suspect the culprit was javascript. I decided to whip up a program to make surfing the net even easier for me




In the beginning, I tried to parse google, but accessing that engine via a bot is 'Forbidden 403'. Blah blah blah. I went over to bing and saw that they haven't implemented anything of the sort. The program takes one parameter and is very fast. All in all, it took about 10 minutes to make. Here's the code:



import urllib2
from bs4 import BeautifulSoup
import requests

stripped_titles = []
stripped_descriptions = []

def search(term):

url = urllib2.urlopen("https://www.bing.com/news/search?q="+term+"+&FORM=HDRSC6")
a = url
content = url.read()
soup = BeautifulSoup(content, 'lxml')

# fetch descriptions/descriptions and append
titles = soup.find_all(class_='title')
for t in titles:
stripped_titles.append(t.get_text(strip=True).encode('utf-8'))

descriptions = soup.find_all(class_='snippet')
for d in descriptions:
stripped_descriptions.append(d.get_text(strip=True).encode('utf-8'))

print '\n'
print '\n'
print "----------RESULTS-----------"
print '\n'
for x, y in zip(stripped_titles, stripped_descriptions):
print x + '-'
print y
print '\n'

while 1:
var1 = raw_input("Search: ")
search(var1)


If you have any other ideas of things that could be automated, let me know. K love u bye

Comments

Popular posts from this blog

How many lays can I get in 14 days - Long Term Field Report

What's up, reader. I was working on a mini coding project and had an epiphany. I'm going to approach and screen as many women as I possibly can for the rest of this month to see how many times I can get laid and if screening is truly the best method for me. ------RESULTS------- Screening is definitely for me.