Очистка и парсинг страницы Википедии

Вы могли использовать любой из языков ДОЛЛАРА, которые позволяют действительно легко хост Ваша собственная платформа сценариев. Однако Вы не должны использовать язык сценариев для этого. Вы могли использовать C# и скомпилировать его с поставщиком кода C#. Пока Вы загружаете его в его собственном AppDomain, можно загрузить и разгрузить его к содержанию основы.

5
задан Damjan Pavlica 26 October 2015 в 14:00
поделиться

7 ответов

I'm going to go with suggesting regex for targeted data extraction in a mixed HTML data stream.

There are already RegEx libraries on the phone, they are sort of hidden though - you can expose them with a few simple calls using RegexKitLite (make sure to scroll down and get the light version). It ends up being a class with a few extensions on NSString that lets you do regexs, then you would define a regex with two captured matches - one for the number, and one for the content, along with a number of non-captured matches for the enclosing and intermediate tags. Even though it's a "lite" version of standard RegEX it sill supports just about any ability you would need.

The API approach is promising but once you get the raw markup you're probably going to have to take a similar regex approach to parsing data out of that. It still might make sense if it reduces regex complexity and data transfer time though, no reason you can't combine both approaches.

1
ответ дан 18 December 2019 в 14:48
поделиться

Добавьте & format = fmt в конец запроса, как описано в API: Data_formats . Ваш запрос выглядит следующим образом: Запрос JSON , например. Вы можете указать XML, JSON или многие другие форматы.

Вы можете легко проанализировать все разделы, а затем просто отобразить выходные данные в формате HTML в веб-просмотре.

4
ответ дан 18 December 2019 в 14:48
поделиться

Given that pages on Wikipedia are stored as plaintext, and input by users as plaintext, you're not going to get a structured data set from it.

3
ответ дан 18 December 2019 в 14:48
поделиться

I have scraped a lot of data from WP in various ways. the format depends on a lot of things including what type of subdomain the information is in and when it was entered. The main text is free format and there is no simple way to scrape it. The infoboxes are in a special WP format which has changed over the years. It wasn't designed to be scraped.

There is a database backing WP which is somewhat more structured.

By far your best strategy is to contact the Wikipedians in the domain you wish to scrape - they will know about the database format and may well be able to help - they will certainly want to help as they will want to see WP in semantic form (such as DBPedia - http://dbpedia.org/About).

3
ответ дан 18 December 2019 в 14:48
поделиться

Does Python count? ;) It is accessible from Objective-C. And there are great modules for scraping purposes: Beautiful Soap and/or mechanize, you can also consider lxml.

2
ответ дан 18 December 2019 в 14:48
поделиться

это определенно не способ сделать это на любом языке.

если какой-либо сайт в сети предоставит свои данные в хорошей форме, это будет википедия.

рассмотрите возможность получения статьи в формате XML, RDF или, возможно, даже в формате JSON.

0
ответ дан 18 December 2019 в 14:48
поделиться

У меня есть приложение для iPhone, которое выполняет парсинг экрана, используя следующее:

Используя YQL, вы можете получать любую информацию из Интернета, используя запросы XPATH против ДОМ.

Лично я считаю, что это намного лучше, чем использование Regex. Опять же, я знаю только очень простые регулярные выражения.

0
ответ дан 18 December 2019 в 14:48
поделиться
Другие вопросы по тегам:

Похожие вопросы: