Python Forum
search API calls in different format
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
search API calls in different format
#1
Yacy is a self-host search engine with an API

When I search via the web panel it produces real results in JSON format. For example searching "python":
https://search.simplifiedprivacy.is/yacy...ery=python

But when I try do it via python, it shows up with weird URLs like “yacysearch.json?query=python” in the URLs and a totally different format.

here's the code I used to test:


import requests
import json
entry = input("Enter search:")
api_url1 = f"https://search.simplifiedprivacy.is/yacysearch.json?query={entry}"
response1 = requests.get(api_url1)
round2 = response1.json()
pretty = json.dumps(round2, indent=2)
print(pretty)
Reply
#2
I don't know what you are typing in for 'entry', but the following works fine:
>>> import requests
>>> import json
>>> 
>>> response = requests.get("https://search.simplifiedprivacy.is/yacysearch.json?query=python")
>>> response.status_code
200
>>>
Reply
#3
Yeah but if I print() the JSON, then the URLs are mangled.
Reply
#4
any opinion on this mangled URL issue? thank you
Reply
#5
I did not have a problem just using your code, the output of pretty is 2390 lines, which I will not copy here.

I have, for example:

Output:
"link": "https://www.linuxquestions.org/questions/syndicated-linux-news-67/lxer-python-python-python-aka-python-3-a-745438-print/"
and

Output:
"image": "https://www.linuxquestions.org/questions/images/LinuxQuestions.png",
The latter shows those cute little penguins if pasted in my browser!

Both links work fine. Both are unmangled.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Calls to Attributes of a Class SKarimi 3 4,643 Apr-22-2021, 04:18 PM
Last Post: SKarimi
  Trying to search excel for a value in row then format row curranjohn46 5 17,470 Oct-04-2019, 02:23 PM
Last Post: curranjohn46
  Need help with a function that calls other functions. skurrtboi 4 3,484 Sep-30-2019, 09:28 PM
Last Post: stullis
  Testing function calls jenselme 1 3,297 Jul-25-2018, 10:33 AM
Last Post: Larz60+
  function state between calls Skaperen 5 6,363 Feb-08-2018, 02:20 AM
Last Post: Skaperen
  Is there another way to do a bunch of methods calls ? Windspar 7 6,068 Jan-02-2018, 06:26 PM
Last Post: Windspar
  Tracing function calls PyRaider 1 4,756 Oct-25-2016, 03:44 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020