用IE developer Tools调试下。你可以打开JS Profiler面板,记录下,看看怎么调用的。

解决方案 »

  1.   

    外部浏览器里真实用鼠标左键点击打开窗口,或者右键点一下后,超链接里多出了spm=1.1000386.5982201.1.8Z0FfX按理肯定有个js中有这个对鼠标的响应事件,一来找起来麻烦,二来找出来后添加到C#中有点困惑,我直接控制ie的,没用webbrower
    或者直接类似这个的获取"登录"这个元素的屏幕坐标的代码,找图之类虽然速度挺快,毕竟维护起来不靠谱,
      

  2.   


    using System;
    using System.IO;
    using System.Linq;
    using SHDocVw;
    using mshtml;class Program
    {
    static void Main()
    {
    var q = from InternetExplorer proc in new ShellWindows()
    where Path.GetFileName(proc.FullName).ToLower().StartsWith("iexplore")
    select proc; var ie = q.FirstOrDefault();
    if (ie == null)
    return; ie.Navigate("https://login.taobao.com/member/login.jhtml");
    ie.DocumentComplete +=ie_DocumentComplete; Console.WriteLine("Press any key to exit");
    Console.ReadKey();
    } static void ie_DocumentComplete(object pDisp, ref object URL)
    {
    var ie = (SHDocVw.WebBrowser) pDisp;
    if (((string)URL).StartsWith("https://login.taobao.com/member/login.jhtml"))
    {
    var username = ((IHTMLDocument2) ie.Document).all.item("TPL_username_1") as IHTMLInputElement;
    username.value = "xxxxxx";
    var password = ((IHTMLDocument2) ie.Document).all.item("TPL_password_1") as IHTMLInputElement;
    password.value = "xxx";
    var submit = ((IHTMLDocument2) ie.Document).all.item("J_SubmitStatic") as IHTMLElement;
    submit.click();
    }
    }
    }
      

  3.   

    楼上的同学,我问的不是登录的代码,不是进login.jhtml填表点击,我纠结的是链接里的
    ?spm=......,用程序click事件出来的没spm码,手动在浏览器点击的有spm码,或者手动右键链接后,链接也自动加上了spm码
      

  4.   

    你举个具体例子,哪个连接有问题?什么叫用程序click事件出来的没spm码?
      

  5.   

    很多都有这个问题的,比如这个登录链接用成程序click手动点或者用鼠标右键后
      

  6.   

    那就用模拟鼠标点击好了:using System;
    using System.Drawing;
    using System.IO;
    using System.Linq;
    using System.Runtime.InteropServices;
    using System.Threading;
    using System.Windows.Forms;
    using SHDocVw;
    using mshtml;class Program
    {
    [STAThread]
    static void Main()
    {
    var ie = new ShellWindows().OfType<InternetExplorer>()
    .FirstOrDefault(w => Path.GetFileName(w.FullName).ToLower().StartsWith("iexplore"));
    if (ie == null)
    return; var doc = ie.Document as IHTMLDocument3;
    var link = doc.getElementsByTagName("a").OfType<IHTMLElement>()
    .FirstOrDefault(a => a.innerText == "登录") as IHTMLElement2; if (link == null)
    return;

    var rect = link.getBoundingClientRect(); // client rectangle
    var win = ((IHTMLDocument2)doc).parentWindow as IHTMLWindow3;
    var pt = new Point(rect.left + win.screenLeft, rect.top + win.screenTop);
    pt.Offset((rect.right-rect.left)/2, (rect.bottom-rect.top)/2); ShowWindow((IntPtr)ie.HWND, SW_SHOW);
    SetForegroundWindow((IntPtr) ie.HWND);
    Thread.Sleep(1000);

    var cursor = new Cursor(Cursor.Current.Handle);
    Cursor.Position = pt;

    mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, (uint)pt.X, (uint)pt.Y, 0, 0);
    } [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
    public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, uint dwExtraInfo); [DllImport("user32.dll")]
    static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); [DllImport("user32")]
    public static extern int SetForegroundWindow(IntPtr hwnd); private const int SW_SHOW = 5;
    private const int MOUSEEVENTF_LEFTDOWN = 0x02;
    private const int MOUSEEVENTF_LEFTUP = 0x04;
    }
      

  7.   

    兄弟,您好,我最近也在做类似的东西,发现SPM时淘宝用来跟踪买家行为的,所以他必须要触发到。
    我这边也是用 element.click(),来触发的,进店的来源还是 直接进店,然后 用 模拟鼠标点击(跟帖子里面的实现差不多,多了个鼠标的随机移动,我以为是要触发mouse_move)的,也是直接进店。
    不知道你最后怎么解决的?感觉正如你说的,是淘宝在脚本懂了手脚,还希望你能指导下我,非常感谢啊。
    这问题困扰我三个多星期了。谢谢啊
      

  8.   

    http://open.taobao.com/doc/detail.htm?id=959
      

  9.   

    楼主 问题怎样搞定的,能让链接带上spm?
      

  10.   


    SPM时淘宝用来跟踪买家行为的,所以他必须要触发到。