title: Python - getting Flipkart product ID
body: <p>I was trying to scrape Flipkart website to get the product ids. I used <a href="https://www.flipkart.com/search?q=samsung%20mobiles&amp;otracker=start&amp;as-show=on&amp;as=off" rel="nofollow noreferrer">this link</a> for listing all the products. The product url holds the PID. So I was trying to get the url, and following is my code.</p>
  
  <pre><code>&gt;&gt;&gt; from bs4 import BeautifulSoup
  &gt;&gt;&gt; import requests
  &gt;&gt;&gt; url = "https://www.flipkart.com/search?q=samsung%20mobiles&amp;otracker=start&amp;as-show=on&amp;as=off"
  &gt;&gt;&gt; data = requests.get(url, headers={
      "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36"
  }).content
  &gt;&gt;&gt; soup = BeautifulSoup(data, "lxml")
  &gt;&gt;&gt; soup.find_all('div', 'col zZCdz4')
  []
  </code></pre>
  
  <p>But it was returning an empty list. So I tried using their API to get the product ID, following is the code:</p>
  
  <pre><code>&gt;&gt;&gt; import requests
  &gt;&gt;&gt; headers = ({"x-user-agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.92 Safari/537.36 FKUA/website/41/website/Desktop"})
  &gt;&gt;&gt; data = requests.get("https://affiliate-api.flipkart.net/affiliate/1.0/booksApi/jerilwork.json", headers=headers)
  </code></pre>
  
  <p>It returned me some details in json format, and the following is a single item of the dictionary:</p>
  
  <pre><code>{"name":"Cursive Writing","url":"https://affiliate-api.flipkart.net/affiliate/1.0/booksFeeds/jerilwork/category/bks-fnf-fs6-mak-8lf.json?expiresAt=1479434177786&amp;sig=4710ea4a9633e4e046938c7d47cf53b7","id":"8lf","subCategories":[]}
  </code></pre>
  
  <p>In their <a href="http://affiliate.flipkart.com/api-docs/af_prod_ref.html#prodfeedapi-label" rel="nofollow noreferrer">API Documentation</a> it is mentioned that the above mentioned URL <code>"url":"https://affiliate-api.flipkart.net/affiliate/1.0/booksFeeds/jerilwork/category/bks-fnf-fs6-mak-8lf.json?expiresAt=1479434177786&amp;sig=4710ea4a9633e4e046938c7d47cf53b7"</code> can be used to get the product ID and I tried but its returning me a empty list. </p>
  
  <p>Can someone help me with this. Where am I doing the mistake. How can I get the product ID's of any category (eg. mobile phones or samsung mobile phones). Kindly help. </p>