sundios / Google-rank-tracker

SEO: Python script + shell script and cronjob to check ranks on a daily basis

Home Page:https://www.kwrds.ai

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not working, Need help in fixing

susheelseth opened this issue · comments

Hi Sundios,

First of all thanks for making the script.

I have followed all the installation steps and also updated the robobrowser browser.py
robobrowser/) and open browser.py and add change from werkzeug import cached_property to from werkzeug.utils import cached_property

Installed Python version - pip-21.1.1

Here is the folder DIR:
.gitignore
Google-rank-tracker-master.zip
keywords.xls
rank_legacy.py
rank.py
README.md
Readme.txt

Getting the following error:

C:\Users\susheel.seth>D:\xampp\htdocs\Python\Ranking\rank.py https://www.xyz.com/ desktop
Traceback (most recent call last):
  File "D:\xampp\htdocs\Python\Ranking\rank.py", line 160, in <module>
    keywords = pd.read_excel('keywords.xls')
  File "C:\Users\susheel.seth\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\util\_decorators.py", line 299, in wrapper
    return func(*args, **kwargs)
  File "C:\Users\susheel.seth\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\excel\_base.py", line 336, in read_excel
    io = ExcelFile(io, storage_options=storage_options, engine=engine)
  File "C:\Users\susheel.seth\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\excel\_base.py", line 1062, in __init__
    ext = inspect_excel_format(
  File "C:\Users\susheel.seth\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\excel\_base.py", line 938, in inspect_excel_format
    with get_handle(
  File "C:\Users\susheel.seth\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\common.py", line 648, in get_handle
    handle = open(handle, ioargs.mode)
FileNotFoundError: [Errno 2] No such file or directory: 'keywords.xls'

Please let me know if you need any further info from my end.

Thanks
Susheel

Hello Susheel,

It looks like you dont have the keywords.xls file. Make sure you have a file in the same path you are running the script. So C:\Users\susheel.seth>D:\xampp\htdocs\Python\Ranking\keywords.xls should exist.

In this file, you can add the keywords you want to check your rankings.

Let me know if you have any other questions

Hi sundios,

Thanks for your prompt response. I have checked the keywords.xls file and it's there in the same folder.

Here is the DIR of that folder for reference:
D:\xampp\htdocs\Python\Ranking\
.gitignore
Google-rank-tracker-master.zip
keywords.xls
rank_legacy.py
rank.py
README.md
Readme.txt

Regards,
Susheel

From the error log you shared FileNotFoundError: [Errno 2] No such file or directory: 'keywords.xls' its clear its not finding the keywords file. Make sure you are running the script in the same folder as keywords.xls lives.

You could also try the following:

Open rank.py and go to line 160 change it to the following:

keywords = pd.read_excel('D:\xampp\htdocs\Python\Ranking\keywords.xls')

This way you are calling the full path of where the keyword.xls lives.

Let me know if this solves the issue

Thanks Sundios.

Now it's showing some other error.

C:\Users\susheel.seth>D:\xampp\htdocs\Python\Ranking\rank.py https://www.xyz.com/ desktop
  File "D:\xampp\htdocs\Python\Ranking\rank.py", line 161
    keywords = pd.read_excel('D:\xampp\htdocs\Python\Ranking\keywords.xls')
                                                                          ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-4: truncated \xXX escape

Im not very familiar with Windows but I think you have two solutions.

Change the path to:

Duplicate backslashes:
keywords = pd.read_excel("D:\\xampp\\htdocs\\Python\\Ranking\\keywords.xls")

prefix the string with r (to produce raw string):

keywords = pd.read_excel(r"D:\xampp\htdocs\Python\Ranking\keywords.xls")

I also updated the single qutoe to be double quote (' to be ")

Thanks for your quick response. We are doing great progress.

I made the suggested changes and it asked me to install xlrd.

After that the script is working as I can see following output.

C:\Users\susheel.seth>D:\xampp\htdocs\Python\Ranking\rank.py https://www.xyz.com/ desktop
Using desktop device
loan software
The user Agent you used was ----> Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko)
Sleeping time is 10 Seconds
lending software
The user Agent you used was ----> Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko)
Sleeping time is 3 Seconds
nbfc software
The user Agent you used was ----> Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko)
Sleeping time is 1 Seconds
 press close to exit

But it's not generating a csv file as mentioned in the readme.
This will also generate a CSV file in the folder where rank.py is located. This will include all the information the terminal is showing.
PS: I also checked the keywords.xls file just to check if it's adding the keywords ranking column there itself but it's all just input keywords.

Nice! I'm glad is working now.

So to get the files you should do the same that you did for keywords.xls but on the output file.

So on line 152 you should include your path like this:

file = 'D:\\xampp\\htdocs\\Python\\Ranking\\' + datetime.date.today().strftime("%d-%m-%Y")+'-' +keyword + '-' + device +'.csv'

This will make sure that you are saving the file in that specific path. You can even create a folder and save them all there.

Thank you so much sundios for your help.

It's now generating the csv as well :)

Just one suggestion if you could help, it will saves a lot of time. Now, we have everything...

  1. Able to search multiple keywords on google search via xls file.
  2. Fetching top 100 results
  3. Searching the input URL and counting the ranking
  4. Saving the result in a csv file.

In most of the cases, we have to search for competitors rank as well for the same keyword.
Since, we are checking for a single website via command rank.py https://www.xyz.com/ desktop can we tweak a little bit to find the rank of other input URLs.

E.g. rank.py https://www.xyz1.com/ https://www.xyz2.com/ https://www.xyz3.com/ desktop so that the scripts checks for all the websites (xyz2, xyz3) and save their corresponding ranking in the csv file.

Output could be like this:

Keyword | URL1Rank | URL1 | URL2Rank | URL2 | URL3Rank | URL3 | Device | Date
loan software | 42 | https://www.xyz1.com/xxxx | 30 | https://www.xyz2.com/xxxx | 11 | https://www.xyz3.com/xxxx desktop | ########

If something could be done then it will be very helpful and it saves a lot of time. Please have a thought on this.

That's a good idea. I will see how to add a competitors parameter in case somebody want to check additional urls on a specific query.

Maybe you can close this issue and open a new one so I can tag it as new feature

Sure, I am closing it as my issue is resolved now.

Thanks a ton :)