[Code] Scrape Google PAA Using Python + Requests

iam_ironman

Power Member
Joined
Oct 20, 2014
Messages
578
Reaction score
176
Python code to scrape PAA from google

Seen a post made by @RealDaddy that PAA would increase your organic traffic, so I made a code to scrape PAA text with python

Code:
import requests
from lxml.html import fromstring
import lxml.html
header = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36',
        'Accept-Language': 'en-US,en;q=0.9',
        'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9'
        }
query = 'weight loss tips'
response = requests.get(f'https://www.google.com/search?q={query}&start=0', headers=header).text
tree = lxml.html.fromstring(response)
node = tree.xpath('//@data-q')
print(node)

Thanks
 
Last edited:
Python code to scrape PAA from google

Seen a post made by @RealDaddy that PAA would increase your organic traffic, so I made a code to scrape PAA text with python

Code:
import requests
from lxml.html import fromstring
import lxml.html
header = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36',
        'Accept-Language': 'en-US,en;q=0.9',
        'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9'
        }
query = 'weight loss tips'
response = requests.get(f'https://www.google.com/search?q={query}&start=0', headers=header).text
tree = lxml.html.fromstring(response)
node = tree.xpath('//@data-q')
print(node)

Thanks
Now this is interesting, I don't know shit about python and how to customize this but I have a couple of developer friends.

@OP does this scrap the answers as well?
 
Sorry for the noob question but how do I run the code?
Will create a video how to use it

Now this is interesting, I don't know shit about python and how to customize this but I have a couple of developer friends.

@OP does this scrap the answers as well?
It scrape only questions
 
Python code to scrape PAA from google

Seen a post made by @RealDaddy that PAA would increase your organic traffic, so I made a code to scrape PAA text with python

Code:
import requests
from lxml.html import fromstring
import lxml.html
header = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36',
        'Accept-Language': 'en-US,en;q=0.9',
        'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9'
        }
query = 'weight loss tips'
response = requests.get(f'https://www.google.com/search?q={query}&start=0', headers=header).text
tree = lxml.html.fromstring(response)
node = tree.xpath('//@data-q')
print(node)

Thanks
That a nice code but your ip will be blocked after too many requests even when you are rotating user agents you need to use proxies at least , i can design user friendly interface for it with the nessecarry adjustement (for free ofcourse) if you guys interested
 
Can you scrape multiple queries at once with this script and proxies?
 
Nice one, bookmarking it to my paa bookmark stash.
 
Still waiting for the video on how to run it.
You can search python introduction, python for newbies, etc, sure you will find how to install python 3 and run scripts. It's as easy as save the code as a .py file, for example googleppa.py, install python3 and then run the code from cmd typing 'python googleppa.py'
 
You can search python introduction, python for newbies, etc, sure you will find how to install python 3 and run scripts. It's as easy as save the code as a .py file, for example googleppa.py, install python3 and then run the code from cmd typing 'python googleppa.py'
import requests
ModuleNotFoundError: No module named 'requests'
 
scraping also answers, and ability to specify the amount of questions/answers You wanna get would be sweet
 
Back
Top