import requests
import time
def monitor_news(keywords, interval_minutes=30):
"""Monitor news for specific keywords."""
seen_links = set()
while True:
for keyword in keywords:
response = requests.get("https://api.ujeebu.com/serp",
headers={"ApiKey": "YOUR_API_KEY"},
params={
"search": keyword,
"search_type": "news",
"extra_params": "&tbs=qdr:h", # Past hour only
"results_count": 20
})
for article in response.json().get("news", []):
if article["link"] not in seen_links:
seen_links.add(article["link"])
print(f"NEW: {article['title']}")
print(f" {article['siteName']} - {article['date']}")
time.sleep(interval_minutes * 60)
# Monitor multiple topics
monitor_news(["AI news", "tech startups", "cybersecurity"])
const axios = require('axios');
async function monitorNews(keywords, intervalMinutes = 30) {
const seenLinks = new Set();
while (true) {
for (const keyword of keywords) {
let response;
try {
response = await axios.get('https://api.ujeebu.com/serp', {
headers: { 'ApiKey': 'YOUR_API_KEY' },
params: {
search: keyword,
search_type: 'news',
extra_params: '&tbs=qdr:h', // Past hour only
results_count: 20
}
});
} catch (err) {
continue; // Skip this keyword if the request fails
}
for (const article of response.data.news || []) {
if (!seenLinks.has(article.link)) {
seenLinks.add(article.link);
console.log(`NEW: ${article.title}`);
console.log(` ${article.siteName} - ${article.date}`);
}
}
}
await new Promise(resolve => setTimeout(resolve, intervalMinutes * 60 * 1000));
}
}
// Monitor multiple topics
monitorNews(['AI news', 'tech startups', 'cybersecurity']);
from ujeebu_python import UjeebuClient
import time
uj = UjeebuClient(api_key="YOUR_API_KEY")
def monitor_news(keywords, interval_minutes=30):
"""Monitor news for specific keywords."""
seen_links = set()
while True:
for keyword in keywords:
res = uj.serp(params={
"search": keyword,
"search_type": "news",
"extra_params": "&tbs=qdr:h", # Past hour only
"results_count": 20
})
for article in res.json().get("news", []):
if article["link"] not in seen_links:
seen_links.add(article["link"])
print(f"NEW: {article['title']}")
print(f" {article['siteName']} - {article['date']}")
time.sleep(interval_minutes * 60)
# Monitor multiple topics
monitor_news(["AI news", "tech startups", "cybersecurity"])
const { UjeebuClient } = require('@ujeebu-org/ujeebu-sdk');
const client = new UjeebuClient("YOUR_API_KEY");
async function monitorNews(keywords, intervalMinutes = 30) {
const seenLinks = new Set();
while (true) {
for (const keyword of keywords) {
let res;
try {
res = await client.serp({
search: keyword,
search_type: 'news',
extra_params: '&tbs=qdr:h', // Past hour only
results_count: 20
});
} catch (err) {
continue; // Skip this keyword if the request fails
}
for (const article of res.data.news || []) {
if (!seenLinks.has(article.link)) {
seenLinks.add(article.link);
console.log(`NEW: ${article.title}`);
console.log(` ${article.siteName} - ${article.date}`);
}
}
}
await new Promise(resolve => setTimeout(resolve, intervalMinutes * 60 * 1000));
}
}
// Monitor multiple topics
monitorNews(['AI news', 'tech startups', 'cybersecurity']);
<?php
function monitor_news($keywords, $intervalMinutes = 30) {
$seenLinks = [];
while (true) {
foreach ($keywords as $keyword) {
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'https://api.ujeebu.com/serp?' . http_build_query([
'search' => $keyword,
'search_type' => 'news',
'extra_params' => '&tbs=qdr:h', // Past hour only
'results_count' => 20,
]),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['ApiKey: YOUR_API_KEY'],
]);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
foreach ($data['news'] ?? [] as $article) {
if (!isset($seenLinks[$article['link']])) {
$seenLinks[$article['link']] = true;
echo "NEW: {$article['title']}\n";
echo " {$article['siteName']} - {$article['date']}\n";
}
}
}
sleep($intervalMinutes * 60);
}
}
// Monitor multiple topics
monitor_news(['AI news', 'tech startups', 'cybersecurity']);
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"strconv"
"time"
)
type NewsItem struct {
Title string `json:"title"`
Link string `json:"link"`
SiteName string `json:"siteName"`
Date string `json:"date"`
}
func monitorNews(keywords []string, intervalMinutes int) {
seenLinks := map[string]bool{}
for {
for _, keyword := range keywords {
q := url.Values{
"search": {keyword},
"search_type": {"news"},
"extra_params": {"&tbs=qdr:h"}, // Past hour only
"results_count": {strconv.Itoa(20)},
}
req, _ := http.NewRequest("GET", "https://api.ujeebu.com/serp?"+q.Encode(), nil)
req.Header.Set("ApiKey", "YOUR_API_KEY")
res, err := http.DefaultClient.Do(req)
if err != nil {
continue
}
body, _ := io.ReadAll(res.Body)
res.Body.Close()
var data struct {
News []NewsItem `json:"news"`
}
json.Unmarshal(body, &data)
for _, article := range data.News {
if !seenLinks[article.Link] {
seenLinks[article.Link] = true
fmt.Printf("NEW: %s\n", article.Title)
fmt.Printf(" %s - %s\n", article.SiteName, article.Date)
}
}
}
time.Sleep(time.Duration(intervalMinutes) * time.Minute)
}
}
func main() {
// Monitor multiple topics
monitorNews([]string{"AI news", "tech startups", "cybersecurity"}, 30)
}
package main
import (
"encoding/json"
"fmt"
"log"
"time"
"github.com/ujeebu/ujeebu-go"
)
type serpNews struct {
News []struct {
Title string `json:"title"`
Link string `json:"link"`
SiteName string `json:"siteName"`
Date string `json:"date"`
} `json:"news"`
}
func monitorNews(client *ujeebu.Client, keywords []string, intervalMinutes int) {
seenLinks := map[string]bool{}
for {
for _, keyword := range keywords {
body, _, err := client.Serp(ujeebu.SerpParams{
Search: keyword,
SearchType: "news",
ExtraParams: "&tbs=qdr:h", // Past hour only
ResultsCount: 20,
})
if err != nil {
continue
}
var data serpNews
json.Unmarshal(body, &data)
for _, article := range data.News {
if !seenLinks[article.Link] {
seenLinks[article.Link] = true
fmt.Printf("NEW: %s\n", article.Title)
fmt.Printf(" %s - %s\n", article.SiteName, article.Date)
}
}
}
time.Sleep(time.Duration(intervalMinutes) * time.Minute)
}
}
func main() {
client, err := ujeebu.NewClient("YOUR_API_KEY")
if err != nil {
log.Fatal(err)
}
// Monitor multiple topics
monitorNews(client, []string{"AI news", "tech startups", "cybersecurity"}, 30)
}