Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed with selector "h1:first" on webpage http://en.m.wikipedia.org/wiki/Katy_Perry #42

Closed
jnixdev opened this issue Oct 20, 2015 · 5 comments

Comments

@jnixdev
Copy link

jnixdev commented Oct 20, 2015

Getting following error/exception:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Attempted to use selector with error: Error Domain=HTMLSelectorErrorDomain Code=1 "Unrecognized pseudo class" UserInfo=0x7fd24389f2d0 {NSLocalizedFailureReason=Error near character 8: Unrecognized pseudo class

h1:first
^        , HTMLSelectorInputString=h1:first, HTMLSelectorLocation=8, NSLocalizedDescription=Unrecognized pseudo class}'

At below line number two
#1 HTMLDocument *document = [HTMLDocument documentWithString:markup];
#2 HTMLElement * element = [document firstNodeMatchingSelector:@"h1:first"];

@nolanw
Copy link
Owner

nolanw commented Oct 20, 2015

That error is trying to tell you that :first isn't a thing in CSS selectors.

Which element are you trying to get to on that page? If it's just the first <h1> anywhere in the page, you can simply do [document firstNodeMatchingSelector:@"h1"].

@jnixdev
Copy link
Author

jnixdev commented Oct 21, 2015

Thanks, You are correct.

@nolanw
Copy link
Owner

nolanw commented Oct 21, 2015

Did you manage to get the elements you needed from the page?

@jnixdev
Copy link
Author

jnixdev commented Oct 21, 2015

Yes, thanks a lot.
I was considering it will fork for CSS Pseudo-classes as well. (ref:http://www.w3schools.com/css/css_pseudo_classes.asp),
I really appreciate your work, really great library.

@nolanw
Copy link
Owner

nolanw commented Oct 21, 2015

Most of those should work. The ones that won't work are the ones that don't make much sense for HTMLReader, like :visited (because HTMLReader doesn't know what you've visited).

@nolanw nolanw closed this as completed Oct 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants