Proof-of-concept shell based on IPython #13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey, @redapple !
Before anything, I'd like to reinforce that this is just a proof-of-concept: I know the code is far from perfect and the ideas here will need some lapidating if we decide to go this route. The purpose is more like starting the discussion. :)
I started this because my usual workflow when doing scraping involves a lot of work in the shell: that's where I end up testing most of the CSS/XPath expressions.
I think this is in part because one ends up distrusting the browser tools for creating selectors after trying to scrape from sites with heavy Javascript usage, so even when using an extension like XPath Helper you usually still want to double-check the expressions in the shell.
So, I don't know if many other scraping devs also do that, this PoC is supposed to help users that are a bit like me. =)
Here is a sample session of using it:
Okay, that was fun, but it also shows a few problems in the current implementation:
test()
shows only the text, but often you'd want to see the actual HTMLFor problem 1, I think a proper solution would be to offer two functions for testing, but I can't think of good names... :P
For problem 2, I think a proper solution would involve to enable switching between contexts among the levels, so you could be "inside" the list selector, try out and add expressions for that context, and then go back up and continue on the upper level. This will require some more thinking, so I'll wait for your feedback before pursuing it.
Overall, it's pretty cool to be able to test expressions without worrying if they're CSS or XPath and the feedback loop in the shell fells so much tighter then trying out expressions in the browser/shell and then editing the parselet in the text editor.
I realize this was pretty long, sorry about that!
Please let me know what you think. =)