Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7018295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:01:44+00:00 2026-05-27T23:01:44+00:00

I’m working on a web scraper that sometimes needs to remember a particular page,

  • 0

I’m working on a web scraper that sometimes needs to remember a particular page, then go to some other pages and then go back to that page. Currently I just save the URL of the page, but that doesn’t work for pages like Google Maps, where the URL is always the same.

I can see that the GoBack method does go back to the previous page, so somehow the WebBrowser remembers what the previous pages was. How can I do this manually? I could count how many pages have been visited since the page I want to go back to and then call GoBack as many times as necessary, but that’s pretty unreliable and un-elegant. So I wonder how could I implement a GoBackToAParticularPage method.

There is one thing I think would get me closer to a solution: saving the URL of all frames and then putting them back when going back to that page. I think that would solve at lease the Google Maps problems. I have not tested it yet. I don’t know exactly what would it be the proper way to do this. I would need to wait for the frames to exist before setting their URLs.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:01:45+00:00Added an answer on May 27, 2026 at 11:01 pm

    In case anyone else can benefit from it, here is how I ended up doing it. The only caveat is that if the travel log to has too many pages in between, the entry might not exist any more. There is probably a way to increase the history size, but since there have to be some limit, I use the TravelLog.GetTravelLogEntries method to see whether the entry still exists or not and if not, use the URL instead.

    Most of this code came from PInvoke.

    using System;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;
    using System.Collections.Generic;
    
    namespace TravelLogUtils
    {
        [ComVisible(true), ComImport()]
        [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
        [GuidAttribute("7EBFDD87-AD18-11d3-A4C5-00C04F72D6B8")]
        public interface ITravelLogEntry
        {
            [return: MarshalAs(UnmanagedType.I4)]
            [PreserveSig]
            int GetTitle([Out] out IntPtr ppszTitle); //LPOLESTR LPWSTR
    
            [return: MarshalAs(UnmanagedType.I4)]
            [PreserveSig]
            int GetURL([Out] out IntPtr ppszURL); //LPOLESTR LPWSTR
        }
    
        [ComVisible(true), ComImport()]
        [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
        [GuidAttribute("7EBFDD85-AD18-11d3-A4C5-00C04F72D6B8")]
        public interface IEnumTravelLogEntry
        {
            [return: MarshalAs(UnmanagedType.I4)]
            [PreserveSig]
            int Next(
                [In, MarshalAs(UnmanagedType.U4)] int celt,
                [Out] out ITravelLogEntry rgelt,
                [Out, MarshalAs(UnmanagedType.U4)] out int pceltFetched);
    
            [return: MarshalAs(UnmanagedType.I4)]
            [PreserveSig]
            int Skip([In, MarshalAs(UnmanagedType.U4)] int celt);
    
            void Reset();
    
            void Clone([Out] out ITravelLogEntry ppenum);
        }
    
        public enum TLMENUF
        {
            /// <summary>
            /// Enumeration should include the current travel log entry.
            /// </summary>
            TLEF_RELATIVE_INCLUDE_CURRENT = 0x00000001,
            /// <summary>
            /// Enumeration should include entries before the current entry.
            /// </summary>
            TLEF_RELATIVE_BACK = 0x00000010,
            /// <summary>
            /// Enumeration should include entries after the current entry.
            /// </summary>
            TLEF_RELATIVE_FORE = 0x00000020,
            /// <summary>
            /// Enumeration should include entries which cannot be navigated to.
            /// </summary>
            TLEF_INCLUDE_UNINVOKEABLE = 0x00000040,
            /// <summary>
            /// Enumeration should include all invokable entries.
            /// </summary>
            TLEF_ABSOLUTE = 0x00000031
        }
    
        [ComVisible(true), ComImport()]
        [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
        [GuidAttribute("7EBFDD80-AD18-11d3-A4C5-00C04F72D6B8")]
        public interface ITravelLogStg
        {
            [return: MarshalAs(UnmanagedType.I4)]
            [PreserveSig]
            int CreateEntry([In, MarshalAs(UnmanagedType.LPWStr)] string pszUrl,
                [In, MarshalAs(UnmanagedType.LPWStr)] string pszTitle,
                [In] ITravelLogEntry ptleRelativeTo,
                [In, MarshalAs(UnmanagedType.Bool)] bool fPrepend,
                [Out] out ITravelLogEntry pptle);
    
            [return: MarshalAs(UnmanagedType.I4)]
            [PreserveSig]
            int TravelTo([In] ITravelLogEntry ptle);
    
            [return: MarshalAs(UnmanagedType.I4)]
            [PreserveSig]
            int EnumEntries([In] int TLENUMF_flags, [Out] out IEnumTravelLogEntry ppenum);
    
            [return: MarshalAs(UnmanagedType.I4)]
            [PreserveSig]
            int FindEntries([In] int TLENUMF_flags,
            [In, MarshalAs(UnmanagedType.LPWStr)] string pszUrl,
            [Out] out IEnumTravelLogEntry ppenum);
    
            [return: MarshalAs(UnmanagedType.I4)]
            [PreserveSig]
            int GetCount([In] int TLENUMF_flags, [Out] out int pcEntries);
    
            [return: MarshalAs(UnmanagedType.I4)]
            [PreserveSig]
            int RemoveEntry([In] ITravelLogEntry ptle);
    
            [return: MarshalAs(UnmanagedType.I4)]
            [PreserveSig]
            int GetRelativeEntry([In] int iOffset, [Out] out ITravelLogEntry ptle);
        }
    
        [ComImport, ComVisible(true)]
        [Guid("6d5140c1-7436-11ce-8034-00aa006009fa")]
        [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
        public interface IServiceProvider
        {
            [return: MarshalAs(UnmanagedType.I4)]
            [PreserveSig]
            int QueryService(
                [In] ref Guid guidService,
                [In] ref Guid riid,
                [Out] out IntPtr ppvObject);
        }
    
        public class TravelLog
        {
            public static Guid IID_ITravelLogStg = new Guid("7EBFDD80-AD18-11d3-A4C5-00C04F72D6B8");
            public static Guid SID_STravelLogCursor = new Guid("7EBFDD80-AD18-11d3-A4C5-00C04F72D6B8");
    
            //public static void TravelTo(WebBrowser webBrowser, int 
            public static ITravelLogEntry GetTravelLogEntry(WebBrowser webBrowser)
            {
                int HRESULT_OK = 0;
    
                SHDocVw.IWebBrowser2 axWebBrowser = (SHDocVw.IWebBrowser2)webBrowser.ActiveXInstance;
                IServiceProvider psp = axWebBrowser as IServiceProvider;
                if (psp == null) throw new Exception("Could not get IServiceProvider.");
    
                IntPtr oret = IntPtr.Zero;            
                int hr = psp.QueryService(ref SID_STravelLogCursor, ref IID_ITravelLogStg, out oret);            
                if ((oret == IntPtr.Zero) || (hr != HRESULT_OK)) throw new Exception("Failed to query service.");
    
                ITravelLogStg tlstg = Marshal.GetObjectForIUnknown(oret) as ITravelLogStg;
                if (null == tlstg) throw new Exception("Failed to get ITravelLogStg");            
                ITravelLogEntry ptle = null;
    
                hr = tlstg.GetRelativeEntry(0, out ptle);
    
                if (hr != HRESULT_OK) throw new Exception("Failed to get travel log entry with error " + hr.ToString("X"));
    
                Marshal.ReleaseComObject(tlstg);
                return ptle;
            }
    
            public static void TravelToTravelLogEntry(WebBrowser webBrowser, ITravelLogEntry travelLogEntry)
            {
                int HRESULT_OK = 0;
    
                SHDocVw.IWebBrowser2 axWebBrowser = (SHDocVw.IWebBrowser2)webBrowser.ActiveXInstance;
                IServiceProvider psp = axWebBrowser as IServiceProvider;
                if (psp == null) throw new Exception("Could not get IServiceProvider.");
    
                IntPtr oret = IntPtr.Zero;
                int hr = psp.QueryService(ref SID_STravelLogCursor, ref IID_ITravelLogStg, out oret);
                if ((oret == IntPtr.Zero) || (hr != HRESULT_OK)) throw new Exception("Failed to query service.");
    
                ITravelLogStg tlstg = Marshal.GetObjectForIUnknown(oret) as ITravelLogStg;
                if (null == tlstg) throw new Exception("Failed to get ITravelLogStg");
    
                hr = tlstg.TravelTo(travelLogEntry);
    
                if (hr != HRESULT_OK) throw new Exception("Failed to travel to log entry with error " + hr.ToString("X"));
    
                Marshal.ReleaseComObject(tlstg);
            }
    
            public static HashSet<ITravelLogEntry> GetTravelLogEntries(WebBrowser webBrowser)
            {
                int HRESULT_OK = 0;
    
                SHDocVw.IWebBrowser2 axWebBrowser = (SHDocVw.IWebBrowser2)webBrowser.ActiveXInstance;
                IServiceProvider psp = axWebBrowser as IServiceProvider;
                if (psp == null) throw new Exception("Could not get IServiceProvider.");
    
                IntPtr oret = IntPtr.Zero;
                int hr = psp.QueryService(ref SID_STravelLogCursor, ref IID_ITravelLogStg, out oret);
                if ((oret == IntPtr.Zero) || (hr != HRESULT_OK)) throw new Exception("Failed to query service.");
    
                ITravelLogStg tlstg = Marshal.GetObjectForIUnknown(oret) as ITravelLogStg;
                if (null == tlstg) throw new Exception("Failed to get ITravelLogStg");
    
                //Enum the travel log entries
                IEnumTravelLogEntry penumtle = null;
                tlstg.EnumEntries((int)TLMENUF.TLEF_ABSOLUTE, out penumtle);
                hr = 0;
                ITravelLogEntry ptle = null;
                int fetched = 0;
                const int MAX_FETCH_COUNT = 1;
    
                hr = penumtle.Next(MAX_FETCH_COUNT, out ptle, out fetched);
                Marshal.ThrowExceptionForHR(hr);
    
                HashSet<ITravelLogEntry> results = new HashSet<ITravelLogEntry>();
    
                for (int i = 0; 0 == hr; i++)
                {
                    if (ptle != null) results.Add(ptle);
                    hr = penumtle.Next(MAX_FETCH_COUNT, out ptle, out fetched);
                    Marshal.ThrowExceptionForHR(hr);
                }
    
                Marshal.ReleaseComObject(penumtle);
                Marshal.ReleaseComObject(tlstg);
    
                return results;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
Seemingly simple, but I cannot find anything relevant on the web. What is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.