php - scraping with xpath, giving an error -


I am trying to get text from a page scrap using xpath, now I'm returning an error And do not know why! Keeping in mind, I am a very new PHP user, it is for a university project that I have taken and its supporters are very challenging: P but it should be.

This is the code,

  & lt ;? In Php $ html = file_get_contents ( 'http://www.amazon.co.uk/New-Apple-iPod-touch generation / DP / B0040GIZTI / ref = br_lf_m_1000333483_1_1_img ie = UTF8 & amp ;? s = electronics & amp; pf_rd_p = 229,345,967 & amp; pf_rd_s = center -3 & amp; pf_rd_t = 1401 & amp; pf_rd_i = +1000333483 & amp; pf_rd_m =; A3P5ROKL5A1OLE & amp pf_rd_r = 1ZW9HJW2KN2C2MTRJH60 '); $ Dom = new DOMDocument (); $ Dom- & gt; LoadHTML ($ HTML); $ Xpath = new DOMXpath ($ dom); $ In_stock = $ xpath- & gt; Query ( "/ html / body / div [@ id = 'divsinglecolumnminwidth'] / [[id = 'Handbel'] / table [3] / TB [3] / TD / div / span"); ? & Gt;   

I get the following error ...

Warning: DOMDocument :: loadHTML () [domdocument.loadhtml]: Unexpected end tag: head unit , Line: 2664C: \ xampp \ htdocs \ scraping \ domxpath.php on line 1

Almost 100 times!

Any help really appreciated! , To fix it should be really easy: P

  $ xpath = new DOMXpath ($ Dom); $ Expr = "/ html / body / div [@ id = 'divsinglecolumnminwidth'] / form [@ id = 'Handbak'] / table [3] / tr [3] / TD / div / span"; $ Node = $ xpath- & gt; Query ($ expr); // Return Domed List Object // You can check length property i.e. $ Nodes- & gt; Length echo $ nodes-> Items (0) - & gt; Nodevelle; // Get the first domonode object and its value   

In addition to this, you have to add a stamant. I think it is better to use absolute XPath expression due to execution, but along with relative // ​​form [@ id = 'handbab'] / table [3] / tr [3] / TD / div / span Works are more elastic.

Comments

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -