1

i have a movie site , i need import movie data from IMDB, for doing this i installed Feeds and Feeds XPath Parser for scrapping. i created a content type for movie wiht some field (poster,actors,...)

after that i create a feeds importer called "Movie importer" . i set Parser to "XPath HTML parser".

in the mapping i added xpathparser:0 ,xpathparser:1 and... for field i created for Movie content type.

in the XPath HTML parser settings i added Xpath like this

  • context: //div[@id='overview-top']
  • title: /h1/span[1]
  • poster: /div/a/img
  • Genre: /div[1]/a/span
  • Story: /p[2]
  • stars: /div[3]/a/span
  • movie rate: /div[2]/div[3]/strong/span

It's not working , and i don't know why.

one more thing i am newbie with XPath :(

Here Sample IMDB Page : http://www.imdb.com/title/tt0773262/

1 Answer 1

1

The context XPath expression is for finding a context of all other (variable) expressions. These queries do not have the context prepended, but evaluation starts with (one of the) results as context.

Thus, you may not start your query with /, otherwise search starts at the root again – and the root element is <html/>, not <title/> or any of the others.

For example, the query for the title has to be h1/span[1]. Anyway, I'd better go for the @itemprop attribute instead of a positional attribute: h1/span[@itemprop='name'] or even decouple further from the underlying structure: .//*[@itemprop='name'] and use the Movie schema properties whenever possible, as they are designed for scraping the data and will make it much more robust.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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