lnxpy / mdb-ai-prompted-text

MindsDB (mdb.ai) AI Single-prompting Text Using PyAction
1 stars 0 forks source link

AI: Text Prompting #31

Open lnxpy opened 4 weeks ago

lnxpy commented 4 weeks ago

Text

bring a crawling example in js.

Prompt

help by showing code snippets

Submission Privacy

github-actions[bot] commented 4 weeks ago

Sure! Here is a simple example of web crawling in JavaScript using the node-fetch and cheerio libraries:

const fetch = require('node-fetch');
const cheerio = require('cheerio');

const url = 'https://example.com';

fetch(url)
    .then(response => response.text())
    .then(body => {
        const $ = cheerio.load(body);
        $('a').each((index, element) => {
            const link = $(element).attr('href');
            console.log(link);
        });
    })
    .catch(error => {
        console.error('Error:', error);
    });

In this example, we are fetching the HTML content of a webpage using node-fetch, parsing it with cheerio, and then extracting all the links on the page. You can modify this example based on your specific requirements.