Python Forum
How to use data from an API, to create an alert?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to use data from an API, to create an alert?
#4
(Apr-20-2021, 09:20 PM)Axel_Erfurt Wrote: Do I understand correctly that you want to find something?

import requests
import json

response = requests.get('https://a.4cdn.org/biz/catalog.json')
catalog = json.loads(response.text)

print(catalog[0]['threads'][0].keys())

length = len(catalog)

the_name = "Anonymous"

for x in range(length - 1):
    my_range = 10
    for a in range(my_range):
        name = catalog[x]['threads'][a]['name']
        if name:
            if name == the_name:
                print("found", the_name, "at", a, x)

Hi Axel, correct, I'm trying to search parts of each thread for something. Each thread is a dict containing a 'sub' and a 'com' key, I'm trying to search the value of these for some keywords (I'm using the keyword 'doge' to test). If a keyword is found I'd like to return the value of the 'no' key for that thread.

Thanks!
Reply


Messages In This Thread
RE: How to use data from an API, to create an alert? - by PopFendi - Apr-20-2021, 10:23 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Monitor specific line of code and get alert Olimpiarob 0 1,540 Jul-08-2020, 10:06 AM
Last Post: Olimpiarob
  Python / Selenium Turning Off Alert graham23s 3 8,300 Aug-18-2019, 02:12 PM
Last Post: metulburr
  Issue closing an Modal Alert (popup) leviathan54 8 5,946 Apr-23-2019, 02:00 PM
Last Post: leviathan54

Forum Jump:

User Panel Messages

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