-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Question about the syntax changes on the cli #7
Comments
If it complains that
|
Yeah that did trick. I'm really sorry about wasting your time with these seemingly stupid issues, I'm finding it hard to work productively with ferret. Things that are simple in virutally any programming language become exceedingly difficult in FQL. |
Hey, I'm sorry to hear that you are having difficulties. What could be done to make it better? |
I guess most of the issues are due to the declarative (functional?) design you chose for FQL and how it works. For example, a real estate site I'm crawling has some data on each property with this HTML: <ul class="props">
<li>
<div><span class="icon-wa50-sup"></span> m<sup>2</sup></div>
<div>215</div>
</li>
<li>
<div><span class="icon-wa50-bed"></span> Rooms</div>
<div>4</div>
</li>
<li>
<div><span class="icon-wa50-bath"></span> Bathrooms</div>
<div>3</div>
</li>
<li>
<div><span class="icon-wa50-parking"></span> Parking</div>
<div><i class="icon-wa50-check"></i></div>
</li>
</ul> Not all the elements are always there on all the properties, so to know what I'm getting, I came up with this (some not-relevant code omitted):
As you can see, the lack of if/else makes me nest a lot of ternary operators. Also, to add fields to the
This is just one recent example. |
Well, certain limitations were done intentionally while others were a result of the source of inspiration. And again, most of the time it's the way you solve particular problems and you just need to switch your thought process from imperative to declarative flow. |
The problem was not getting the data, but knowing what type of data it is and appending it to the already existing property object. Instead of doing
And then in the example instead of just showing the icon type, you wanted to iteratively append to the users object with the username as property name. Something like I realize it's a design issue, it's the first thing I said, but sometimes I just feel that if I could write the scripts in for example JS, I would be saving a lot time overthinking how to make things work. And please don't get me wrong, I love ferret and I think it's a great piece of software. |
No worries, you are sharing the problems you are facing with using Ferret and that's fine! Yes, I admit that it might be frustrating at times not being able to mutate objects in queries. I will think about how we can mitigate it in the future releases. |
With the old cli, you could run
ferret --cdp http://127.0.0.1:9222 script.fql
and it would work without problem. What is the equivalent command with the latest cli version? I tried the following:ferret exec --browser-headless --browser-address http://127.0.0.1:9222 script.fql
, errs with not supported: CLICK(...)ferret exec --browser-address http://127.0.0.1:9222 script.fql
, errs with not supported: CLICK(...)ferret exec --runtime http://127.0.0.1:9222 script.fql
andferret exec --runtime http://127.0.0.1:9222 --browser-headless script.fql
, returns HTML code with title Headless remote debuggingThe text was updated successfully, but these errors were encountered: