Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

92
Views
Fetch webpage data and check for a particular text using javascript

I want to fetch data from a webpage and search for a particular text in it. I am able to do it using python but i want to do it using javascript. I am attaching the python code so that you can understand what i am trying to do, and how I can do it using javascript.

import requests
a = requests.get("http://localhost:3000/data")
b = a.text
if("wrong" in b):
  print(b)

Any help will be appreciated.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can do a regex search in javascript like so

fetch('http://google.com')
    .then(function (response) {
        switch (response.status) {
            // status "OK"
            case 200:
                let text = response.text();
                let n = text.search("W3Schools");
                console.log(text,n)
            // status "Not Found"
            case 404:
                throw response;
        }
    })
    .then(function (template) {
        console.log(template);
    })
    .catch(function (response) {
        // "Not Found"
        console.log(response.statusText);
    });

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!