Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am trying to run an incremental search using lynx.

Imagine a page, for example, an index_of page which contains several folders which also contain other subfolders and files. I want to run lynx in a way that I can enter automatically in each folder/page and search for a string, so it returns me the link which contains the string found.

For example, if I am looking for a specific datasheet in http://datasheets.chipdb.org/ so I would try something like

find . -name "mydatasheet.pdf" |lynx -dump http://datasheets.chipdb.org

but that I could run in all subfolders recursively. Maybe some grep or whatever.

How could it be done?

share|improve this question
    
Isn't lynx a text based browser? How can it do an incremental search? –  Ketan Feb 13 at 23:13
    
Well, that's exactly the question. But you can identify the links based on a link pattern. –  Rego Feb 13 at 23:16

1 Answer 1

up vote 0 down vote accepted

Maybe I don't understand your question but if I were trying to find a link to a pdf file I would write a python script. Something like:

#!/usr/bin/env python

import urllib2
import re
from bs4 import BeautifulSoup
def find_links ( url ):
        try:
                soup = BeautifulSoup(urllib2.urlopen( url ).read())
        except:
                return
        links = soup.findAll( "a" )
        for link in links:
                pdfurl = link.get('href')
                m = re.search( "^\?", pdfurl)
                if m:
                        continue
                m = re.search( ".pdf$", pdfurl)
                if m:
                        print "Found a pdf in %s/%s" % (url, pdfurl)
                else:
                        find_links( "%s/%s" % ( url, pdfurl) )

find_links( "http://datasheets.chipdb.org" )

Or a Perl script that uses WWW::Mechanize.

share|improve this answer
    
Yes, that's something like this. Thanks! –  Rego Feb 15 at 2:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.