Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4608210
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:48:46+00:00 2026-05-22T00:48:46+00:00

For a company project, I need to create a web scraping application with PHP

  • 0

For a company project, I need to create a web scraping application with PHP and JavaScript (including jQuery) that will extract specific data from each page of our clients’ websites. The scraping app needs to get two types of data for each page: 1) determine whether certain HTML elements with specific IDs are present, and 2) extract the value of a specific JavaScript variable. The JS variable name is the same on each page, but the value is usually different.

I believe I know how I can get the first data requirement: using the PHP file_get_contents() function to get each page’s HTML and then use JavaScript/jQuery to parse that HTML and search for elements with specific IDs. However, I’m not sure how to get the 2nd piece of data – the JavaScript variable values. The JavaScript variable isn’t even found within each page’s HTML; instead, it is found in an external JavaScript file that is linked to the page. And even if the JavaScript were embedded in the page’s HTML, I know that file_get_contents() would only extract the JavaScript code (and other HTML) and not any variable values.

Can anyone suggest a good approach to getting this variable value for each page of a given website?

EDIT: Just to clarify, I need the values of the JavaScript variables after the JavaScript code has been run. Is such a thing even possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T00:48:46+00:00Added an answer on May 22, 2026 at 12:48 am

    presumably this is impossible because it seems so simple, but if it’s your .js you’re trying to detect, why not just have that .js do something detectable via scrape to the page?

    use the js to populate a tag like this somewhere (via element.innerHTML, presumably):

    <span><!--Important js thing has been activated!--></span>.   
    

    edit: alternately, maybe use a document.write, if the script needs to be detectable onload

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to implement a project that will consume XML Web Service from other
I'm working on a project for my company that uses a socket server (php)
One of the items in the Joel Test is that a project/company should have
I have an old project at our company that uses shell scripting a lot.
At the company I work for we have a Utility project that is referenced
My company is working on a project that needs to read XML files within
I'd like to deploy my ASP.NET MVC application to a web hosting company (like
I am starting a new project where we need to make entering web data
I'm doing a project for a surveying company in Drupal 6. Ultimately, employees will
Situation: I have a large shrink wrapped application that my company bought. It is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.