Imgur TagVote issue python - python

A beginner here, I am using the imgur python library to get tags related to an image. For this I am using the gallery_item_tags method as mentioned here.
However whenever i call the method it gives me an output as shown here.
I have followed the authorization procedure using the needed client id and client secret and i can run all methods not involving TagVotes array. How can i get the required information from this?

You're getting a list of TagVote instances. You probably want the name, you can access it like this:
for tag in tags:
print tag.name

Related

Python Product Tag Update using Shopify API - 400 Error - Product :Required Parameter Missing Or Invalid

Just built my first Shopify store and wanted to use python and API to bulk-update product tags on all our products.
However, I've run into a snag on my PUT call. I keep getting a 400 Response with the message '{"errors":{"product":"Required parameter missing or invalid"}}'.
I've seen other people with similar issues on here but none of their solutions seem to be working for me.
Has anyone else run into this problem that can help me figure it out?
Here are some screenshots of my code, a printout of the payload, and the error in the response.
Code, Payload and Response:
I can successfully get the product info using the API and was originally sending the entire JSON payload that was returned just updated it with my product tags and sent it back through the API.
To narrow potential pain points, I'm keeping it simple now and just including "id" and "tags" in the payload but still get the same error.
We figured it out! It turns out that when we initially created the store we used a domain store name that was misspelled so we created a new domain store name with the correct spelling. However, the original domain store name was not deleted (not even sure it can be), and even though the new domain store name forwards to the original one and allows for GET requests, for PUT requests we had to use the original misspelled domain store name and the PUTs work fine.
I figured this out by using fiddler to capture a manual product update via the Shopify website to see what the payload looked like and that's why I noticed the store URL was different than the one we were using.
Hope this helps someone with a similar issue!

I would like to get only the contents of an index which I created in AWS elasticsearch without json key

I need the content of a json data indexed in AWS elastic search without getting Json key(when the indexid is provided)
I have tried filter_path to get the source content. But it has the key of the json content. I need only the value to be displayed and not the whole content from ._source
For eg:
my indexing API is this:
es_enpoint/mysite/_doc/1
{"_index":"mysite","_type":"_doc","_id":"1","_version":3,"found":true,"_source":{"description": {"our world needs more trees"}}
I tried this:
es_enpoint/mysite/_doc/1?filter_path=_source
got result:
{"_source":{"description": {"our world needs more trees"}}
But my expected result is:
{"our world needs more trees"}
without any other parameters. Can some one help on this?
Welcome to StackOverflow
Here is what you are looking for !! the official documentation page
For Elastic 6
Use the /{index}/{type}/{id}/_source endpoint to get just the _source
field of the document, without any additional content around it
For Elastic 7
Use the /{index}/_source/{id} endpoint to get just the _source field
of the document, without any additional content around it.
The endpoint changed with elastic7 and removal of types
So in your case, you should try
es_enpoint/mysite/_doc/1/_source?_source=description
I hope it will help you

Is there a way to get Tag objects instead of Reference ones when listing tags from a repository?

I'm able to successfully list tags from a repository using github3 using:
repo.iter_refs(subspace='tags')
That results in a generator of github3.git.Reference objects. Is there a way for me use a similar mechanism to get github3.git.Tag objects, instead? Right now I'm forced to convert each Reference object into my own version of Tag.
So the only way to get a github3.git.Tag object back is if you're trying to retrieve a specific annotated tag (which is a tag created in a very specific manner).
If this is what you're trying to do then your code would look something like
tags = [repo.tag(r.object.sha) for r in repo.iter_refs(subspace='refs')]
You can get a lightweight tag (which is what most tags on GitHub actually are) by either your current method or by doing repo.iter_tags(). Either will work. The latter will return github3.repos.RepoTag, not a github3.git.Tag though because the API returns much different information for each.

Python Amazon Product Api not able to get image

I'm using python amazon product api and I can't seem to get the url for the image of the product.
Here is my code so far
for book in amz_api.item_search('Books', Keywords='cookies', ResponseGroup='Large', limit=10):
print book.ItemAttributes.Large
But I get this reply
AttributeError: no such child: {http://webservices.amazon.com/AWSECommerceService/2011-08-01}Large
Any help would be apprecicated
To access the image URLs, you can try to change your code to use one of the following:
print book.SmallImage.URL
print book.MediumImage.URL
print book.LargeImage.URL
The error is because there is no "Large" attribute in ItemAttributes. The image URLs are available in a different part of the response.
The Large Response Group (ResponseGroup='Large') returns a lot of data. According to the docs it's for demonstration purposes and not intended for production applications. To make your code production ready, you might need a different approach, such as the Images Response Group (ResponseGroup='Images').
Also, the python type for the book variable in the above code is:
<type 'lxml.objectify.ObjectifiedElement'>
While debugging, you can look at all the data available in book using something like this:
from lxml import objectify
print(objectify.dump(book))

Selenium, issue with retrieving url from image object

I'm working with the application, which I have made test in my old tool (HP QTP), now I need convert it to selenium(python webdriver), I have issue with specific part, during the test flow I receive image with the value, (data is static only for testing), so I know what value I should send for response.
In HP QTP I solved it by 'if conditional' and loop (VB code below):
For Each elem As HtmlElement In WebBrowser1.Document.GetElementsByTagName("img")
If elem.GetAttribute("src") = "http://URL/image_1.png" Then
WebBrowser1.Document.GetElementById("response").SetAttribute("value", "70")
End If
If elem.GetAttribute("src") = "http://URL/image_2.png" Then
WebBrowser1.Document.GetElementById("response").SetAttribute("value", "80")
End If
I don't know how it should looks in python. I didn't found equivalent function for "elem.GetAttribute("")" in Python.
Unfortunately I have lack experience with python so I'm looking for solution or hints for this issue.
There is a get_attribute method available in python API. You need to find the element and be able to perform same action you are doing in vb. Consult this and here is an example how to do it.

Categories

Resources