SlideShare a Scribd company logo
Project: “I’m Feeling Lucky”
Google Search
Guided by,
Dr. Srivani P
Assistant professor
Presented by,
B C Narendra
5th sem CSE
Introduction
• Whenever I search a topic on Google, I
don’t look at just one search result at a
time. By middle-clicking a search result
link (or clicking while holding ctrl), I open
the first several links in a bunch of new
tabs to read later.
• It would be nice if I could simply
type a search term on the command line
and have my computer automatically
open a browser with all the top search
results in new tabs.
•
This is what your program does:
 Gets search keywords from the command line
arguments.
 Retrieves the search results page.
 Opens a browser tab for each result.
This means your code will need to do the following:
 Read the command line arguments from sys.argv.
 Fetch the search result page with the requests
module.
 Find the links to each search result.
 Call the webbrowser.open() function to open the
web browser
Open a new file editor window and save it as lucky.py.
Step 1: Get the Command Line Arguments and Request the Search Page
Before coding anything,you first need to know the URL of the search result
page. You can see that the result page has a URL like
https://www.google.com/search?q=SEARCH_TERM_HERE.
The requests module can download this page and then you can use Beautiful
Soup to find the search result links in the HTML. Finally, you’lluse the
webbrowser module to open those links in browser tabs.
import requests, sys, webbrowser, bs4
print('Googling') # display text while downloading the Google page
res = requests.get('http://google.com/search?q=' + ' '.join(sys.argv[1:]))
res.raise_for_status()
Step 2: Find All the Results
Now you need to use BeautifulSoup to extract the top search result links
from your downloadedHTML. You can’t just search for all tags, because there
are lots of links you don’t care about in the HTML. Instead, you must inspect
the search result page with the browser’s developertools to try to find a
selector that will pick out only the links you want.
After doing a Google search for Beautiful Soup, you can open the browser’s
developertools and inspect some of the link elements on the page. They look
incrediblycomplicated, somethinglike this: BeautifulSoup: We called him
Tortoise because he taught us.
soup = bs4.BeautifulSoup(res.text )
linkElems = soup.select('.r a')
Step 3: Open Web Browsers for Each Result
Finally, we’ll tell the program to open web browser tabs for our results. Add
the following to the end of your program:
linkElems = soup.select('.r a')
numOpen = min(5, len (linkElems))
for i in range(numOpen):
webbrowser.open('http://google.com' + linkElems[i].get('href'))
By default, you open the first five search results in new tabs using the
webbrowser module. However, the user may have searched for something
that turned up fewer than five results.
On each iteration of the loop, you use webbrowser.open()to open a new tab in
the web browser.
Thank You

More Related Content

Similar to Presentation_ADP.pptx

Week 9 10 ppt-how_searchworks
Week 9 10 ppt-how_searchworksWeek 9 10 ppt-how_searchworks
Week 9 10 ppt-how_searchworks
carolyn oldham
 
Modern JavaScript and SEO
Modern JavaScript and SEOModern JavaScript and SEO
Modern JavaScript and SEO
OIKIO Digital Performance Agency
 
Il 01-search engines
Il 01-search enginesIl 01-search engines
Il 01-search engines
Darryl Sherman
 
Scrape box presentation
Scrape box presentationScrape box presentation
Scrape box presentation
Elephate1
 
Ultimate Guide to White Hat SEO using Scrapebox
Ultimate Guide to White Hat SEO using ScrapeboxUltimate Guide to White Hat SEO using Scrapebox
Ultimate Guide to White Hat SEO using Scrapebox
Łukasz Rogala
 
How to Scrape Amazon Best Seller Lists with Python and BeautifulSoup.pdf
How to Scrape Amazon Best Seller Lists with Python and BeautifulSoup.pdfHow to Scrape Amazon Best Seller Lists with Python and BeautifulSoup.pdf
How to Scrape Amazon Best Seller Lists with Python and BeautifulSoup.pdf
Productdata Scrape
 
Introduction of Search Engine & working process.pdf
Introduction of Search Engine & working process.pdfIntroduction of Search Engine & working process.pdf
Introduction of Search Engine & working process.pdf
SAMBaquibillahSagor
 
How to Scrape Amazon Best Seller Lists with Python and BeautifulSoup.pptx
How to Scrape Amazon Best Seller Lists with Python and BeautifulSoup.pptxHow to Scrape Amazon Best Seller Lists with Python and BeautifulSoup.pptx
How to Scrape Amazon Best Seller Lists with Python and BeautifulSoup.pptx
Productdata Scrape
 
Search Engine Optimization (SEO)
Search Engine Optimization (SEO)Search Engine Optimization (SEO)
Search Engine Optimization (SEO)
Nandu B Rajan
 
Thuvien it.org--seo-workflow-link-assistant.com
Thuvien it.org--seo-workflow-link-assistant.comThuvien it.org--seo-workflow-link-assistant.com
Thuvien it.org--seo-workflow-link-assistant.com
Minh Nguyễn
 
Google ppt by amit
Google ppt by amitGoogle ppt by amit
Google ppt by amit
DAVV
 
Web driver selenium simplified
Web driver selenium simplifiedWeb driver selenium simplified
Web driver selenium simplified
Vikas Singh
 
Keyword basics-final
Keyword basics-finalKeyword basics-final
Keyword basics-finalpdrlvn74
 
Search Engine Optimization
Search Engine OptimizationSearch Engine Optimization
Search Engine Optimization
shrishail uttagi
 
Hacking
HackingHacking
Hacking
Ashish Ranjan
 
Social buzz club
Social buzz clubSocial buzz club
Social buzz clubLori Gama
 
Lesson 4.pdf
Lesson 4.pdfLesson 4.pdf
Lesson 4.pdf
Shivani835601
 
SEO Training in Hyderabad | SEO Classes in Hyderbad | SEO Coaching in Hyde...
SEO Training in Hyderabad |  SEO  Classes in Hyderbad | SEO Coaching in  Hyde...SEO Training in Hyderabad |  SEO  Classes in Hyderbad | SEO Coaching in  Hyde...
SEO Training in Hyderabad | SEO Classes in Hyderbad | SEO Coaching in Hyde...Prasad Reddy
 

Similar to Presentation_ADP.pptx (20)

Week 9 10 ppt-how_searchworks
Week 9 10 ppt-how_searchworksWeek 9 10 ppt-how_searchworks
Week 9 10 ppt-how_searchworks
 
Modern JavaScript and SEO
Modern JavaScript and SEOModern JavaScript and SEO
Modern JavaScript and SEO
 
Il 01-search engines
Il 01-search enginesIl 01-search engines
Il 01-search engines
 
Scrape box presentation
Scrape box presentationScrape box presentation
Scrape box presentation
 
Ultimate Guide to White Hat SEO using Scrapebox
Ultimate Guide to White Hat SEO using ScrapeboxUltimate Guide to White Hat SEO using Scrapebox
Ultimate Guide to White Hat SEO using Scrapebox
 
Google
GoogleGoogle
Google
 
How to Scrape Amazon Best Seller Lists with Python and BeautifulSoup.pdf
How to Scrape Amazon Best Seller Lists with Python and BeautifulSoup.pdfHow to Scrape Amazon Best Seller Lists with Python and BeautifulSoup.pdf
How to Scrape Amazon Best Seller Lists with Python and BeautifulSoup.pdf
 
Introduction of Search Engine & working process.pdf
Introduction of Search Engine & working process.pdfIntroduction of Search Engine & working process.pdf
Introduction of Search Engine & working process.pdf
 
How to Scrape Amazon Best Seller Lists with Python and BeautifulSoup.pptx
How to Scrape Amazon Best Seller Lists with Python and BeautifulSoup.pptxHow to Scrape Amazon Best Seller Lists with Python and BeautifulSoup.pptx
How to Scrape Amazon Best Seller Lists with Python and BeautifulSoup.pptx
 
Search Engine Optimization (SEO)
Search Engine Optimization (SEO)Search Engine Optimization (SEO)
Search Engine Optimization (SEO)
 
Thuvien it.org--seo-workflow-link-assistant.com
Thuvien it.org--seo-workflow-link-assistant.comThuvien it.org--seo-workflow-link-assistant.com
Thuvien it.org--seo-workflow-link-assistant.com
 
Google ppt by amit
Google ppt by amitGoogle ppt by amit
Google ppt by amit
 
Web driver selenium simplified
Web driver selenium simplifiedWeb driver selenium simplified
Web driver selenium simplified
 
Keyword basics-final
Keyword basics-finalKeyword basics-final
Keyword basics-final
 
Search Engine Optimization
Search Engine OptimizationSearch Engine Optimization
Search Engine Optimization
 
Hacking
HackingHacking
Hacking
 
Social buzz club
Social buzz clubSocial buzz club
Social buzz club
 
Lesson 4.pdf
Lesson 4.pdfLesson 4.pdf
Lesson 4.pdf
 
SEO Training in Hyderabad | SEO Classes in Hyderbad | SEO Coaching in Hyde...
SEO Training in Hyderabad |  SEO  Classes in Hyderbad | SEO Coaching in  Hyde...SEO Training in Hyderabad |  SEO  Classes in Hyderbad | SEO Coaching in  Hyde...
SEO Training in Hyderabad | SEO Classes in Hyderbad | SEO Coaching in Hyde...
 
Lvr ppt
Lvr pptLvr ppt
Lvr ppt
 

More from mukul narayana

Note for Artificial Neural Network - ANN by Aman Kumar _ LectureNotes.pdf
Note for Artificial Neural Network - ANN by Aman Kumar _ LectureNotes.pdfNote for Artificial Neural Network - ANN by Aman Kumar _ LectureNotes.pdf
Note for Artificial Neural Network - ANN by Aman Kumar _ LectureNotes.pdf
mukul narayana
 
churchturingthesis-160906170827.pptx
churchturingthesis-160906170827.pptxchurchturingthesis-160906170827.pptx
churchturingthesis-160906170827.pptx
mukul narayana
 
Ch11.ppt
Ch11.pptCh11.ppt
Ch11.ppt
mukul narayana
 
Energy Management Presentation (1).ppt
Energy Management Presentation (1).pptEnergy Management Presentation (1).ppt
Energy Management Presentation (1).ppt
mukul narayana
 

More from mukul narayana (6)

Note for Artificial Neural Network - ANN by Aman Kumar _ LectureNotes.pdf
Note for Artificial Neural Network - ANN by Aman Kumar _ LectureNotes.pdfNote for Artificial Neural Network - ANN by Aman Kumar _ LectureNotes.pdf
Note for Artificial Neural Network - ANN by Aman Kumar _ LectureNotes.pdf
 
Ch11.ppt
Ch11.pptCh11.ppt
Ch11.ppt
 
ch15.ppt
ch15.pptch15.ppt
ch15.ppt
 
churchturingthesis-160906170827.pptx
churchturingthesis-160906170827.pptxchurchturingthesis-160906170827.pptx
churchturingthesis-160906170827.pptx
 
Ch11.ppt
Ch11.pptCh11.ppt
Ch11.ppt
 
Energy Management Presentation (1).ppt
Energy Management Presentation (1).pptEnergy Management Presentation (1).ppt
Energy Management Presentation (1).ppt
 

Recently uploaded

Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
Online aptitude test management system project report.pdf
Online aptitude test management system project report.pdfOnline aptitude test management system project report.pdf
Online aptitude test management system project report.pdf
Kamal Acharya
 
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
ssuser7dcef0
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
Fundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptxFundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptx
manasideore6
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
Kamal Acharya
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
Intella Parts
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
camseq
 
An Approach to Detecting Writing Styles Based on Clustering Techniques
An Approach to Detecting Writing Styles Based on Clustering TechniquesAn Approach to Detecting Writing Styles Based on Clustering Techniques
An Approach to Detecting Writing Styles Based on Clustering Techniques
ambekarshweta25
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
yokeleetan1
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
Dr Ramhari Poudyal
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
NidhalKahouli2
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 

Recently uploaded (20)

Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
Online aptitude test management system project report.pdf
Online aptitude test management system project report.pdfOnline aptitude test management system project report.pdf
Online aptitude test management system project report.pdf
 
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
Fundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptxFundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptx
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
 
An Approach to Detecting Writing Styles Based on Clustering Techniques
An Approach to Detecting Writing Styles Based on Clustering TechniquesAn Approach to Detecting Writing Styles Based on Clustering Techniques
An Approach to Detecting Writing Styles Based on Clustering Techniques
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 

Presentation_ADP.pptx

  • 1. Project: “I’m Feeling Lucky” Google Search Guided by, Dr. Srivani P Assistant professor Presented by, B C Narendra 5th sem CSE
  • 2. Introduction • Whenever I search a topic on Google, I don’t look at just one search result at a time. By middle-clicking a search result link (or clicking while holding ctrl), I open the first several links in a bunch of new tabs to read later. • It would be nice if I could simply type a search term on the command line and have my computer automatically open a browser with all the top search results in new tabs. •
  • 3. This is what your program does:  Gets search keywords from the command line arguments.  Retrieves the search results page.  Opens a browser tab for each result. This means your code will need to do the following:  Read the command line arguments from sys.argv.  Fetch the search result page with the requests module.  Find the links to each search result.  Call the webbrowser.open() function to open the web browser Open a new file editor window and save it as lucky.py.
  • 4. Step 1: Get the Command Line Arguments and Request the Search Page Before coding anything,you first need to know the URL of the search result page. You can see that the result page has a URL like https://www.google.com/search?q=SEARCH_TERM_HERE. The requests module can download this page and then you can use Beautiful Soup to find the search result links in the HTML. Finally, you’lluse the webbrowser module to open those links in browser tabs. import requests, sys, webbrowser, bs4 print('Googling') # display text while downloading the Google page res = requests.get('http://google.com/search?q=' + ' '.join(sys.argv[1:])) res.raise_for_status()
  • 5. Step 2: Find All the Results Now you need to use BeautifulSoup to extract the top search result links from your downloadedHTML. You can’t just search for all tags, because there are lots of links you don’t care about in the HTML. Instead, you must inspect the search result page with the browser’s developertools to try to find a selector that will pick out only the links you want. After doing a Google search for Beautiful Soup, you can open the browser’s developertools and inspect some of the link elements on the page. They look incrediblycomplicated, somethinglike this: BeautifulSoup: We called him Tortoise because he taught us. soup = bs4.BeautifulSoup(res.text ) linkElems = soup.select('.r a')
  • 6. Step 3: Open Web Browsers for Each Result Finally, we’ll tell the program to open web browser tabs for our results. Add the following to the end of your program: linkElems = soup.select('.r a') numOpen = min(5, len (linkElems)) for i in range(numOpen): webbrowser.open('http://google.com' + linkElems[i].get('href')) By default, you open the first five search results in new tabs using the webbrowser module. However, the user may have searched for something that turned up fewer than five results. On each iteration of the loop, you use webbrowser.open()to open a new tab in the web browser.