ri0t1985 / api-creator

Project that allows you to turn static website data into an API through CSS selectors
MIT License
6 stars 0 forks source link

Allow usage of XPath to select Tags or Attributes #4

Open heiglandreas opened 7 years ago

heiglandreas commented 7 years ago

It would be pretty nice to be able to use XPath as selector-language as well.

pauledenburg commented 7 years ago

Feel free to leave a PullRequest :-)

ri0t1985 commented 7 years ago

This feature is on the roadmap. I plan to allow a user to be able to define the TYPE of selector they wish to use.

The supported types should be CSS, Xpath, and Regex. (Defaulting to CSS if nothing is supplied in order to not break backwards compatibility)

ri0t1985 commented 7 years ago

@heiglandreas The package we're currently using to parse the data already supports Xpath. Can you verify if it works if you provide the selector in the following format? "/html/body/div/p"

heiglandreas commented 7 years ago

Whoot!! Awesome! I'll check that later today!

ri0t1985 commented 7 years ago

@heiglandreas I've just written some unit tests for the Xpath selectors, and these scenarios seem to work just fine :)

screen shot 2017-09-01 at 11 20 03
heiglandreas commented 7 years ago

Yesterday evening I struggeled with the setup and got some weird PDO-Exceptions.

Can you add a further test with f.e. the XPath //a[@Class="test"]? If that works, then everything else should as well ;)

ri0t1985 commented 7 years ago

@heiglandreas

Done, and seems to work just fine. Can you send me a screengrab of the error your received?

screen shot 2017-09-01 at 11 44 55 screen shot 2017-09-01 at 11 45 08
heiglandreas commented 7 years ago

Lemme first perhaps walk through the readme properly and not skip steps ;) I'm sure that help. I might send a PR for that then…

ri0t1985 commented 7 years ago

@heiglandreas Note that 0.3 has just been released, including better xpath support, regex support, and a test call, which you can use to test the response before saving it.

ri0t1985 commented 7 years ago

Woops, didnt mean to close this.

@heiglandreas Did you manage to get it working? :)