1

I am using xidel command to extract text from HTML page. Here is my code

  xidel  http://www.ip-adress.com/ip_tracer/8.8.8.8 --extract "<table>
  <tbody>
 <tr>
 <td>
 <table>
 <tbody>
  <tr> </tr>
 <template:loop>
  <tr> <th> {$field1} </th> <td> ${field2} </td> </tr>
  </template:loop>
  </tbody>
   </table>
   </td>
   <td> </td>
    </tr>
    </tbody>
     </table>
       " 

I have used template method. When I run this code. I don't get error nor any output at the terminal. This is what I get after executing this code

    **** Retrieving (GET): http://www.ip-adress.com/ip_tracer/8.8.8.8 ****
    **** Processing: http://www.ip-adress.com/ip_tracer/8.8.8.8 ****
     ** Current variable state: **

and returns me the $ prompt. I want to know whether the output is stored in any variable?

1 Answer 1

0

The examples given for xidel make it apparent that it writes to the standard output. If you want to capture that information, you must redirect the standard output to a file, or to a shell variable yourself.

For instance, example 10 does this to set variables in bash:

eval "$(xidel http://site -e 'title:=//title' -e 'links:=//a/@href' --output-format bash)"

There is a note at the bottom of the examples pointing to a readme file for xidel (apparently the documentation as such).

1
  • So here is the solution. Backslashing $field1 and $field2 gives the output.<tr> <th> {\$field1} </th> <td> ${\field2} </td> </tr> Nov 10, 2015 at 17:40

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.