1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Displaying a certain line from webpage source code?

Discussion in 'General Scripting Chat' started by Capo Dei Capi, Apr 19, 2015.

  1. Capo Dei Capi

    Capo Dei Capi BANNED BANNED

    Joined:
    Oct 23, 2014
    Messages:
    754
    Likes Received:
    7,211
    Is there anyway that one can download a webpage in command line and have it display what the source code says on a certain line without manually looking for it? I've heard claims of people doing it with curl, but when I tried googling it there is no script or even talk about it.
     
  2. DarkPixel

    DarkPixel Jr. VIP Jr. VIP

    Joined:
    Oct 4, 2011
    Messages:
    1,348
    Likes Received:
    1,252
    Location:
    ↓↓↓↓
    Home Page:
    I googled and found nothing. You could create a batch script to do that though. A simple wrapper for curl with your custom output.
     
    • Thanks Thanks x 1
  3. Gogol

    Gogol Jr. VIP Jr. VIP

    Joined:
    Sep 10, 2010
    Messages:
    3,478
    Likes Received:
    3,108
    Gender:
    Male
    Depends on how the page is rendered. How about splitting the lines with expressions such as [\r\n] ?

    algorithimically, I mean..

    content = get_content(url);
    lines = split_with_regex("#[\r\n]#" , content);
    echo lines[x];
     
    • Thanks Thanks x 1
    Last edited: Apr 19, 2015
  4. jazzc

    jazzc Moderator Staff Member Moderator Jr. VIP

    Joined:
    Jan 27, 2009
    Messages:
    2,642
    Likes Received:
    11,376
    Occupation:
    Pusillanimous Knitter
    Location:
    Buenos Aires
    Grab with curl, pipe to grep, output to file

    curl ... | grep ... > results.txt
     
    • Thanks Thanks x 1