LYNX web request


Results 1 to 4 of 4

Thread: LYNX web request

  1. #1
    Join Date
    Oct 2010
    Posts
    2

    LYNX web request

    Hello. I am new to unix shell scripting and am having some trouble with a program. I am using a lynx web request to dump information from a website. I am trying to display only certain lines containing information I want displayed so I am using | grep "xxx".

    I will only display the problem code and if you need the rest to help me with my problem I will gladly post it.
    Code:
    lynx -dump http://innopac.xxx.org:4500/PATRONAPI/$barcode |
     grep -Eo "EXP.DATE..*|P.TYPE..*|PATRN.NAME..*|TELEPHONE2..*|EMAIL.ADDR..*"
    I am able to retrieve and display the EXP.DATE..* and P.TYPE..* but then the terminal seems to freeze and the only thing I can do is quit the whole program using CTRL + Z. The PATRN.NAME..*, TELEPHONE2..*, and EMAIL.ADDR..* are all on a different page (hitting down arrow key when you just dump information to the terminal) so I imagine I have to simulate a down arrow keypress but am not sure how. I greatly appreciate any help and/or advice. Thank-you in advance.

  2. #2
    Join Date
    May 2004
    Location
    Arizona
    Posts
    76
    Does this work any differently? I am unfamiliar with lynx -dump.

    Code:
    /usr/bin/wget -qO - http://innopac.xxx.org:4500/PATRONAPI/$barcode |
     grep -Eo EXP.DATE..*|P.TYPE..*|PATRN.NAME..*|TELEPHONE2..*|EMAIL.ADDR..*"
    n00b

  3. #3
    Join Date
    Oct 2010
    Posts
    2
    I was able to get the program to process the request but in order to display the fields I have to hit (down arrow, q, left arrow), other combos cause a failure.

    Code:
     
    lynx http://innopac.xxx.org:4500/PATRONAPI/$barcode/dump | grep -oE "EXP.DATE..*|P.TYPE..*|PATRN..*|TELEPHONE2..*|EMAIL.ADDR..*"| head -6
    Weird. Not sure what is wrong with my code but I shouldn't have to hit any keys for request to process. I tried your code Bryon, and same thing, I had to hit some keys for fields to display. I had to add the head -6 at end or else it script would keep repeating fields over and over.

  4. #4
    Join Date
    Jan 2003
    Location
    Austin, Texas
    Posts
    683
    It's really difficult to tell exactly what the problem is without a concrete example but out of curiosity, have you tried w3m instead? You might try using:

    Code:
    w3m -dump http://innopac.xxx.org:4500/PATRONAPI/$barcode |
     grep -Eo "EXP.DATE..*|P.TYPE..*|PATRN.NAME..*|TELEPHONE2..*|EMAIL.ADDR..*"
    Also, have you tried just a simple dump without a grep?

    Code:
    lynx -dump http://innopac.xxx.org:4500/PATRONAPI/$barcode
    If so, does this complete successfully without you having to enter any input?


    The last thing that I would recommend would be to try each grep individually and see if each one works. Then slowly build up the expression one value at a time until it breaks. That might give you a clue. Otherwise, you might just have to issue multiple grep statements. You could pull the page down and save it in a temporary place and then just run multiple grep statements against that temporary variable/file...one statement for each field that you want.
    "The author of that poem is either Homer or, if not Homer, somebody else of the same name."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •