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

  • SEARCH
  • Home
  • 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 3626636
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:47:15+00:00 2026-05-18T23:47:15+00:00

Hi I am doing a screen scrape on a weather website that has inline

  • 0

Hi I am doing a screen scrape on a weather website that has inline styles in it’s div and has no class or id here is their code:

<div class="TodaysForecastContainer">

                    <div class="TodaysForecastContainerInner">
                        <div style="font-size:12px;"><u>This morning</u></div>
                        <div style="position:absolute;top:17px;left:3px;">
                            <a href="forecastPublicExtended.asp#Period0" target="_blank">
                                <img src="./images/wimages/b_cloudy.gif" height="50px" width="50px" alt="weather image">        
                            </a>                    </div>
                        <div style="position:absolute; top:25px; left:57px; text-align:left; height:47px; width:90px;">
                            Sunny Breaks                            </div>
                    </div>

                    <div class="TodaysForecastContainerInner">
                        <div style="font-size:12px;"><u>This afternoon</u></div>
                        <div style="position:absolute;top:17px;left:3px;">
                            <a href="forecastPublicExtended.asp#Period0" target="_blank">
                                <img src="./images/wimages/b_pcloudy.gif" height="50px" width="50px" alt="weather image">       
                            </a>                    </div>
                        <div style="position:absolute; top:25px; left:57px; text-align:left; height:47px; width:90px;">
                            Mix of Sun and Cloud                            </div>
                    </div>

The problem is the absolute position inline style and they have no class or id, I was hoping I could add a class name and remove inline style on div with “This morning”, div containing the image and also remove the link and the div with discription(ex. Sunny Breaks)also changing all of the TodaysForecastContainerInner since it has about 4 forecast. making it similar to:

<div class="day>This morning</div><div class="thumbnail"><img src="sample.jpg"></div><div class="description">Sunny Breaks</div>

I was using :

foreach($html->find('.TodaysForecastContainerInner div') as $e)
echo $e->innertext . '<br>';

which removes all divs living me with u and img tag,
I just can’t style the div with discription I use img and u tag to style the other two divs, I’m just a beginner at php I hope someone could give me advice thank you so much.

  • 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-18T23:47:15+00:00Added an answer on May 18, 2026 at 11:47 pm

    Check out the phpQuery library. It can do jQuery-like manipulation using PHP. This code essentially accomplishes what you are trying to do:

    <?php
    
    include 'phpQuery-onefile.php';
    
    $text = <<<EOF
    <div class="TodaysForecastContainer">
        <div class="TodaysForecastContainerInner">
            <div style="font-size:12px;"><u>This morning</u></div>
            <div style="position:absolute;top:17px;left:3px;">
                    <a href="forecastPublicExtended.asp#Period0" target="_blank">
                            <img src="./images/wimages/b_cloudy.gif" height="50px" width="50px" alt="weather image">        
                    </a>
            </div>
            <div style="position:absolute; top:25px; left:57px; text-align:left; height:47px; width:90px;">
                Sunny Breaks
            </div>
        </div>
        <div class="TodaysForecastContainerInner">
            <div style="font-size:12px;"><u>This afternoon</u></div>
            <div style="position:absolute;top:17px;left:3px;">
                <a href="forecastPublicExtended.asp#Period0" target="_blank">
                    <img src="./images/wimages/b_pcloudy.gif" height="50px" width="50px" alt="weather image">       
                </a>
            </div>
            <div style="position:absolute; top:25px; left:57px; text-align:left; height:47px; width:90px;">
                Mix of Sun and Cloud
            </div>
        </div>
    EOF;
    
    $doc = phpQuery::newDocumentHTML( $text );
    
    $containers = pq('.TodaysForecastContainerInner', $doc);
    foreach( $containers as $container ) {
        $div = pq('div', $container);
    
        $div->eq(0)->removeAttr('style')->addClass('day')->html( pq( 'u', $div->eq(0) )->html() );  
        $div->eq(1)->removeAttr('style')->addClass('thumbnail')->html( pq( 'img', $div->eq(1))->removeAttr('height')->removeAttr('width')->removeAttr('alt') );
        $div->eq(2)->removeAttr('style')->addClass('description');  
    }
    
    print $doc;
    

    Result:

    <div class="TodaysForecastContainer">
      <div class="TodaysForecastContainerInner">
        <div class="day">This morning</div>
        <div class="thumbnail"><img src="./images/wimages/b_cloudy.gif"></div>
        <div class="description">
          Sunny Breaks
        </div>
      </div>
      <div class="TodaysForecastContainerInner">
        <div class="day">This afternoon</div>
        <div class="thumbnail"><img src="./images/wimages/b_pcloudy.gif"></div>
        <div class="description">
          Mix of Sun and Cloud
        </div>
      </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to screen-scrape a website and for that I want to use Http,
I am doing some screen scraping with a library that takes XPath expressions and
Hopefully somebody can point out what I'm doing wrong with my Splash screen here.
I am doing a simple Quiz application that has several questions that the user
Im doing some screen scraping and im getting back a string that appears to
I'm doing a personal, just for fun, project that is using screen scraping to
I'm doing some screen scraping using WATIJ, but it can't read HTML tables (throws
Im doing a TabBarApplication, and a login screen presented with ModalViewController. In the Login
Doing an ajax get request works as expected using the following code: $.ajax({ type:
Doing some homework here (second assignment, still extremely green...). The object is to read

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.