Search code examples
pythongoogle-search-consolegoogle-api-python-clientgoogle-data-apigoogle-data

Downloader.py not returning correct JSON object not working


I am trying to download the search queries using google webmaster and following the simple steps http://googlewebmastercentral.blogspot.in/2011/12/download-search-queries-data-using.html.

While executing the example-simple-downlaod.py I am getting the following error

sites_json = json.loads(available)
  File "/usr/lib/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

I have followed all the steps. Any suggestions appreciated. When I tried to print the available it gives me the below ouput.

<HTML>
<HEAD>
<TITLE>Moved Temporarily</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Moved Temporarily</H1>
The document has moved <A HREF="https://www.google.com/webmasters/tools/downloads-list?siteUrl=http://myurl.com+&amp;hl=en">here</A>.
</BODY>
</HTML>

Update

I am using Ubuntu 14.04 and python version is 2.7.6. While trying to setup the Google data python libraries. I am following the steps given in the guide that is https://developers.google.com/gdata/articles/python_client_lib?csw=1 and while executing the test to check the dependencies and installation I am getting the following error

Running all tests in module atom_tests.mock_http_test
F..
======================================================================
FAIL: testRecordResponse (atom_tests.mock_http_test.MockHttpClientUnitTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/username/Documents/googlewebmaster/gdata-2.0.18/tests/atom_tests/mock_http_test.py", line 49, in testRecordResponse
    self.assertEquals(live_response.status, 200)
AssertionError: 301 != 200

----------------------------------------------------------------------

Rest all of my tests are running ok.

Any suggestions appreciated.


Solution

  • Example usage of the search queries downloader Python script 1) If Python is not already installed on your machine, download and install Python.

    2) Download and install the Google Data APIs Python Client Library.

    3) Create a folder and add the downloader.py script to the newly created folder.

    4) Copy the example-create-spreadsheet.py script to the same folder as downloader.py and edit it to replace the example values for “website,” “email” and “password” with valid values for your Webmaster Tools verified site.

    5) Open a Terminal window and run the example-create-spreadsheet.py script by entering "python

    example-create-spreadsheet.py" at the Terminal window command line:

    NOTE: Use fully qualified domain Example: http://www.yourdomain.com If that doesn't work try with a trailing slash Example: http://www.yourdomain.com/