N
N
NONAME82018-03-06 23:13:36
Swift
NONAME8, 2018-03-06 23:13:36

How to start learning parsing in swift?

How to start learning parsing in swift?
There are tons of tutorials on how to parse data from JSON Placeholder and other similar sites, but what's the point if it only works for these sites, where everything is already in a ready-made format.
What do you need to learn to learn how to parse pages and extract information from them?
And how does it all happen (please explain as simply and in detail as possible)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
doublench21, 2018-03-07
@NONAME8

Do you want to write a scraping tool or want to learn how to use content scraping tools? For the first one, you need to understand well, as the person above already wrote, in dom, xpath and selectors. If you want to use the tools, then you should not delve into the knowledge listed above. Here you need to act according to the situation.
The information is small and it is easy to get to it through the dom tree, then your case is the regular language of the swift language.
Since regular language is a subset of context-free languages ​​and html is just one of them, regular expressions can't always get you what you want. For these purposes, ready-made tools are usually used that parse the dom for you. You just need to specify the selectors and you will get the data you need. Google, there are such libraries on swift.
If the information you need is loaded dynamically, then the response from the server will not contain this data, because Js has not worked yet, so there is no infa. For such pages, you need to use web drivers. This is a kind of browser that you control from the code. Google Webdriver, Selenium, Chrome cli.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question