![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 1 447 Pomógł: 191 Dołączył: 26.03.2008 Ostrzeżenie: (0%) ![]() ![]() |
Mam taki kodzik :
Kod QWebPage page; QWebFrame * frame = page.mainFrame(); frame->setHtml(str); QWebElement document = frame->documentElement(); QWebElementCollection tables = document.findAll(".table"); int numTables = tables.count(); qDebug() << numTables; return; Pod zmienną str znajduje się źródło tej strony : http://panoramafirm.pl/szukaj/mazowieckie,...wa/firmy,1.html Chcę pobrać ilość elementów o klasie table. Niestety program podaje, że tych elementów jest 0. Podczas gdy w rzczywistości jest ich 15. Gdy zamiast ".table" dam "a", to zwraca mi to 17, czyli jakieś linki znajduje ale chyba jest ich ciut za mało. W czym może być problem ? Wszystkie tabelki są w divie o klasie "results" <- tego diva nie mogę pobrać. Mogę za to pobrać div o nazwię 'socialIcons right" ale nie w całości - na nim program kończy parsowanie. Ten post edytował peter13135 4.08.2012, 16:07:05 |
|
|
![]() |
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 18 Pomógł: 1 Dołączył: 1.05.2007 Ostrzeżenie: (0%) ![]() ![]() |
Zrobiłem po swojemu, wklejając kod gdzie trzeba. Debug zwrócił dwie liczby:
0 25 Na szybko wstawiłem ramkę (ui->webView), kod: MainWindow.h Kod #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QWebElementCollection> #include <QWebFrame> #include <QDebug> namespace Ui { class MainWindow; } PS: Bez okien też jakoś się dało, ale nie pamiętam:P class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private slots: void on_webView_loadFinished(bool arg1); private: Ui::MainWindow *ui; }; #endif // MAINWINDOW_H mainwindow.cpp Kod #include "mainwindow.h"
#include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QUrl url("http://panoramafirm.pl/szukaj/mazowieckie,warszawa/firmy,1.html"); ui->webView->setUrl(url); ui->webView->load(url); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_webView_loadFinished(bool arg1) { QWebPage* page = ui->webView->page(); QWebFrame * frame = page->mainFrame(); QWebElement document = frame->documentElement(); QWebElementCollection tables = document.findAll(".table"); int numTables = tables.count(); qDebug() << numTables; } Ten post edytował katsuo 8.08.2012, 18:41:48 |
|
|
![]() ![]() |
![]() |
Aktualny czas: 11.10.2025 - 20:04 |