Bir web sayfasını yüklemek için bir CefSharp.Wpf.ChromiumWebBrowser (Sürüm 47.0.3.0) kullanıyorum. Sayfa yüklendikten sonra bir nokta kaynak kodunu almak istiyorum.HTML kaynak kodunu CefSharp web tarayıcısından edinin
Ben çağrıda:
wb.GetBrowser().MainFrame.GetSourceAsync()
ancak tüm kaynak kodunu (Ben alt çerçeveler vardır bu olduğuna inanıyorum) iade görünmüyor.
ben ararsam:
wb.GetBrowser().MainFrame.ViewSource()
Ben (iç çerçeveler dahil) tüm kaynak kodunu listeleyen görebilirsiniz.
Aynı sonucu ViewSource() ile almak istiyorum. Biri bana doğru yönde işaret edebilir mi lütfen?
Güncelleme -
Not Eklendi Kod örnek: web tarayıcısı çok işaret adresi yalnızca ve 10/03/2016 dahil kadar çalışacak. Bundan sonra, baktığım gibi olmayan farklı veriler gösterebilir. frmSelection.xaml yılında
frmSelection.xaml.cs ise
<cefSharp:ChromiumWebBrowser Name="wb" Grid.Column="1" Grid.Row="0" />
public partial class frmSelection : UserControl
{
private System.Windows.Threading.DispatcherTimer wbTimer = new System.Windows.Threading.DispatcherTimer();
public frmSelection()
{
InitializeComponent();
// This timer will start when a web page has been loaded.
// It will wait 4 seconds and then call wbTimer_Tick which
// will then see if data can be extracted from the web page.
wbTimer.Interval = new TimeSpan(0, 0, 4);
wbTimer.Tick += new EventHandler(wbTimer_Tick);
wb.Address = "http://www.racingpost.com/horses2/cards/card.sd?race_id=644222&r_date=2016-03-10#raceTabs=sc_";
wb.FrameLoadEnd += new EventHandler<CefSharp.FrameLoadEndEventArgs>(wb_FrameLoadEnd);
}
void wb_FrameLoadEnd(object sender, CefSharp.FrameLoadEndEventArgs e)
{
if (wbTimer.IsEnabled)
wbTimer.Stop();
wbTimer.Start();
}
void wbTimer_Tick(object sender, EventArgs e)
{
wbTimer.Stop();
string html = GetHTMLFromWebBrowser();
}
private string GetHTMLFromWebBrowser()
{
// call the ViewSource method which will open up notepad and display the html.
// this is just so I can compare it to the html returned in GetSourceAsync()
// This is displaying all the html code (including child frames)
wb.GetBrowser().MainFrame.ViewSource();
// Get the html source code from the main Frame.
// This is displaying only code in the main frame and not any child frames of it.
Task<String> taskHtml = wb.GetBrowser().MainFrame.GetSourceAsync();
string response = taskHtml.Result;
return response;
}
}
Bazı kodları paylaşabilir misiniz? Sorunu yeniden oluşturamıyorum, "ViewSourceAsync" ile aynı metni "ViewSource" ile aldım. 'Http: // stackoverflow.com' olarak ayarlanmış 'Adres' ile çalıştı (iki çerçeveye, bir 'iframe' ve ana çerçeveye sahiptir) –
Bir bakış ayırdığınız için teşekkürler. Orijinal yayına örnek kaynak ekledim. – Scott