How to jump on specific Page usinig Beautifulsoup
Question: I want to get data for Product which are search by user in python.I am able to
get data from any Urls but depending upon search Jump on that page and Get
data Using beautifulsoup.

I Try this for get data :

    
    
    from bs4 import BeautifulSoup
    import requests
    import urllib2
    
     url="http://amazon.in"
     con=urllib2.urlopen(url).read()    
     soup=BeautifulSoup(con)
     print soup.prettify()
    

But if user want price of IPhone 5s then it will jump to that product page and
get data.

How I get this.


Answer: You just need to do a get request passing the correct params:

    
    
    import requests
    from bs4 import BeautifulSoup
    
    params = {"url":"search-alias=aps","field-keywords":"iphone 5"}
    url = "http://www.amazon.in/s/ref=nb_sb_noss_2"
    
    
    soup = BeautifulSoup(requests.get(url, params=params).content)
    ul = soup.select_one("#s-results-list-atf")
    

ul will be contain all the search results you see on the page. If we run the
code and find the h2 tags inside each anchor, you can see the item
name/description as you see on the page.

    
    
    In [6]: ul = soup.select_one("#s-results-list-atf")
    
    In [7]: for h2 in ul.select("li a h2"):
       ...:         print(h2.text)
       ...:     
    Apple iPhone 5s (Space Grey, 16GB)
    Apple iPhone 5s (Silver, 16GB)
    Supra Lightning 8 Pin To Micro Usb Charge Sync Data Connector Adapter Iphone 5 Ipad 4
    OnePlus 3 (Graphite, 64GB)
    Apple iPhone 5 (Black-Slate, 16GB)
    ROCK 695029068729 Royce Series Shockproof Dual Layer Back Case Cover for Apple iPhone 5 5S,(Grey)
    Apple iPhone 5c (White, 8GB)
    iSAVE Soft Silicone Grid Design Back Case Cover For iPhone 5/5s (BLACK)
    iPaky AT15312 360 Protective Body Case with Tempered Glass for Apple iPhone SE 5 5S,(Black)
    Aeoss 9Pcs Open Pry Screwdriver Repair Tool Kit Set For iPhone 6 Plus 5 5s 5c 4 iPod.
    2 IN 1 Tempered Glass for Iphone 5 5s 5c Explosion Proof Tempered Glass (FRONT AND BACK)
    Itab iphone5sclearsoftgelly Imported Transparent Clear Silicone Jelly Soft Case Back Cover For Apple Iphone 5 5S
    Shivam Earphones EarPods Handsfree Headphones for Apple iPhone 4/4s/5/5s/6/6+ (White)
    USB Power Adapter Wall Charger&Data Cable for iPhone 5/5S/5C/6
    Generic Ios 7 Compatible Data Sync Charging Cable For Apple Iphone 5 5S 6 - White
    Tempered Glass Screen Protector Scratch Guard for Apple Iphone 5 5G 5s
    

