<p>Have a look at the <a href="https://selectorgadget.com/" rel="nofollow noreferrer">SelectorGadget</a> Chrome extension to grab <code>CSS</code> selectors by clicking on the desired element in your browser.</p>
<p><a href="https://replit.com/@DimitryZub1/why-am-i-getting-repetitive-output-while-tryin#main.py" rel="nofollow noreferrer">Code and example in the online IDE</a> to extract PDF's:</p>
<pre class="lang-py prettyprint-override"><code>from bs4 import BeautifulSoup
import requests, lxml

params = {
    &quot;q&quot;: &quot;entity resolution&quot;, # search query
    &quot;hl&quot;: &quot;en&quot;                # language
}

# https://requests.readthedocs.io/en/master/user/quickstart/#custom-headers
headers = {
    &quot;User-Agent&quot;: &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3538.102 Safari/537.36 Edge/18.19582&quot;,
}

html = requests.get(&quot;https://scholar.google.com/scholar&quot;, params=params, headers=headers, timeout=30)
soup = BeautifulSoup(html.text, &quot;lxml&quot;)

for pdf_link in soup.select(&quot;.gs_or_ggsm a&quot;):
  pdf_file_link = pdf_link[&quot;href&quot;]
  print(pdf_file_link)


# output from the first page:
'''
https://linqs.github.io/linqs-website/assets/resources/getoor-vldb12-slides.pdf
http://ilpubs.stanford.edu:8090/859/1/2008-7.pdf
https://drum.lib.umd.edu/bitstream/handle/1903/4241/umi-umd-4070.pdf;sequence=1
https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.169.9535&amp;rep=rep1&amp;type=pdf
https://arxiv.org/pdf/1208.1927
https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.77.6875&amp;rep=rep1&amp;type=pdf
http://da.qcri.org/ntang/pubs/vldb18-deeper.pdf
'''
</code></pre>
<hr />
<p>Alternatively, you can achieve the same thing by using <a href="https://serpapi.com/google-scholar-organic-results" rel="nofollow noreferrer">Google Scholar Organic Results API</a> from SerpApi. It's a paid API with a free plan.</p>
<p>The main difference is that you only need to grab the data from structured JSON instead of figuring out how to extract the data from HTML, how to bypass blocks from search engines.</p>
<p>Code to integrate:</p>
<pre class="lang-py prettyprint-override"><code>from serpapi import GoogleSearch

params = {
    &quot;api_key&quot;: &quot;YOUR_API_KEY&quot;,   # SerpApi API key
    &quot;engine&quot;: &quot;google_scholar&quot;,  # Google Scholar organic reuslts
    &quot;q&quot;: &quot;entity resolution&quot;,    # search query
    &quot;hl&quot;: &quot;en&quot;                   # language
}

search = GoogleSearch(params)
results = search.get_dict()

for pdfs in results[&quot;organic_results&quot;]:
    for link in pdfs.get(&quot;resources&quot;, []):
        pdf_link = link[&quot;link&quot;]
        print(pdf_link)


# output:
'''
https://linqs.github.io/linqs-website/assets/resources/getoor-vldb12-slides.pdf
http://ilpubs.stanford.edu:8090/859/1/2008-7.pdf
https://drum.lib.umd.edu/bitstream/handle/1903/4241/umi-umd-4070.pdf;sequence=1
https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.169.9535&amp;rep=rep1&amp;type=pdf
https://arxiv.org/pdf/1208.1927
https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.77.6875&amp;rep=rep1&amp;type=pdf
http://da.qcri.org/ntang/pubs/vldb18-deeper.pdf
'''
</code></pre>
<hr />
<p>If you want to scrape more data from organic results, there's a dedicated <a href="https://dev.to/dmitryzub/scrape-google-scholar-with-python-32oh#organic_search" rel="nofollow noreferrer">Scrape Google Scholar with Python</a> blog post of mine.</p>
<blockquote>
<p>Disclaimer, I work for SerpApi.</p>
</blockquote>
Why am I getting repetitive output while trying to scrape data from Google Scholar?
<p>I am trying to scrape the PDF links from the search results from Google Scholar. I have tried to set a page counter based on the change in URL, but after the first eight output links, I am getting repetitive links as output.</p>

<pre><code>#!/usr/bin/env python
from mechanize import Browser
from BeautifulSoup import BeautifulSoup
from bs4 import BeautifulSoup
import urllib2
import requests


#modifying the url as per page
urlCounter = 0
while urlCounter &lt;=30:
    urlPart1 = "http://scholar.google.com/scholar?start="
    urlPart2 = "&amp;q=%22entity+resolution%22&amp;hl=en&amp;as_sdt=0,4"
    url = urlPart1 + str(urlCounter) + urlPart2
    page = urllib2.Request(url,None,{"User-Agent":"Mozilla/5.0 (X11; U; Linux i686) Gecko/20071127 Firefox/2.0.0.11"})
    resp = urllib2.urlopen(page)
    html = resp.read()
    soup = BeautifulSoup(html)
    urlCounter = urlCounter + 10

    recordCount = 0
    while recordCount &lt;=9:
        recordPart1 = "gs_ggsW"
        finRecord = recordPart1 + str(recordCount)
        recordCount = recordCount+1

    #printing the links
        for link in soup.find_all('div', id = finRecord):
            linkstring = str(link)
            soup1 = BeautifulSoup(linkstring)
        for link in soup1.find_all('a'):
            print(link.get('href'))
</code></pre>