2

I am trying to extract some info from a web page. Imagine you have a name given to you (Northcentral Siberia, Russia) and want to extract whole line containing this name from a web page. To handle this, I downloaded the web page (https://geofon.gfz-potsdam.de/eqinfo/list.php) into a text file using lynx command (lynx --dump "https://geofon.gfz-potsdam.de/eqinfo/list.php" > text.txt) and tried to grep the line containing the name "Northcentral Siberia, Russia". the following line shows the info in the web page which all are in a row:

2018-05-27 04:27:17 4.8 60.07°N 128.42°E    10  A       Northcentral Siberia, Russia

But when I downloaded the web page into a text file the above line breaks into two lines as follows:

2018-05-27 04:27:17 4.8 60.07°N 128.42°E    10  A   Northcentral 
Siberia, Russia

In this case, if I try to extract this line using its full name (Northcentral Siberia, Russia) and grep, it will fail. How can I deal with that?

7
  • post the crucial raw fragment from the web page to process May 27, 2018 at 16:47
  • 1
    Your question is worded unclearly.  You’re not talking about order, you’re talking about logical units of text being fragmented across lines. P.S. This problem is probably bigger than you realize. May 27, 2018 at 16:55
  • Sorry, English is not my nature language! I edited my question hope to be more clear May 27, 2018 at 17:17
  • As it looks like that for me, does the location name contain a line break? In that case would it be possible to clean the data before writing the file or afterwards?
    – U880D
    May 27, 2018 at 17:20
  • 1
    I don't think so! This case happens only for long lines. I added the web page link to be more clear ... May 27, 2018 at 17:25

1 Answer 1

5

It is because when you use the -dump option to lynx it assumes that your "screen" is 80 columns wide, and the table formatting, etc of the webpage causes that to wrap.

Add in a -width argument and it should work -

lynx -width=200 -dump "https://geofon.gfz-potsdam.de/eqinfo/list.php" > text.txt

1
  • Many thanks for your solution. problem solved :) May 27, 2018 at 20:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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