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?
#1
Hello,

first off I'd like to say I'm very new, and this is my first attempt at using Python to create a useful program for myself, so go easy on me pls.

What I'm trying to create is a program that will search through the API of 4chans /biz/ catalog for some keywords and email me with the thread link when my keywords are being spoken about. To start off I've requested the API and attached it to a variable using:

import requests

response = requests.get('https://a.4cdn.org/biz/catalog.json')
catalog = response.json()
When I print this it returns a lovely big list with other nested dictionaries and lists, as this image illustrates:

[Image: Dict.jpg]

So, I have an 11 item list, one for each page. One level deeper I have a dict -> page : with the value of the page #, and then a list of 20 dicts, with all of the keys and values for each thread.

What I'm trying to do is iterate through each thread, on each page and search the values of 'sub' and 'com' for my keywords, if they show up I want to return the value of the 'no' key for that thread. Then I can append that number to then end of a url and email it to myself every time a new post pops up.

I understand I'm biting off a bit more than I can chew here with my skillset, and I'm not asking for someone to write the code for me, rather, if someone knows any resources that could help me better understand how to search through complicated lists of nested lists and dicts, as alot of the tutorials I've found online either, aren't working with lists this complicated, or trying to do something completely different.

Anyways, thanks for reading,
Pop.
Reply


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

Possibly Related Threads…
Thread Author Replies Views Last Post
  Monitor specific line of code and get alert Olimpiarob 0 1,538 Jul-08-2020, 10:06 AM
Last Post: Olimpiarob
  Python / Selenium Turning Off Alert graham23s 3 8,295 Aug-18-2019, 02:12 PM
Last Post: metulburr
  Issue closing an Modal Alert (popup) leviathan54 8 5,938 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