コード例 #1
0
            override public void __Processor(BotCycle bc)
            {
                for (int i = 0; i < 3; i++)
                {
                    bc.Add(new Product(url: i + Url));
                }

                //list next page
                bc.Add(new Category(url: "qqqqq2", t: T));
            }
コード例 #2
0
            /// <summary>
            /// InputItem can define a method to process it.
            /// When it is not defined within InputItem class, it must be defined in CustomBot as PROCESSOR_[InputItem class name]
            /// </summary>
            /// <param name="bc">BotCycle that keeps the current thread</param>
            override public void __Processor(BotCycle bc)
            {
                bc.Add(new Category(url: Url + "?q=1", t: new Category.Tag(name: "fff", description: "ttttt")));

                //it is possible to get the current CustomBot when access to common members is needed
                ((CustomSession)bc.Session).counter++;
            }
コード例 #3
0
        static public void get_links(int depth2, HttpRoutine hr, BotCycle bc)
        {
            if (depth2 > Bot.Properties.Spider.Default.MaxDownloadLinkDepth)
            {
                return;
            }

            string domain     = Spider.GetDomain(hr.ResponseUrl);
            int    page_count = domain2page_count[domain];

            if (Bot.Properties.Spider.Default.MaxPageCountPerSite > -1 && page_count >= Bot.Properties.Spider.Default.MaxPageCountPerSite)
            {
                return;
            }

            AgileSpider    ags = new AgileSpider(hr.ResponseUrl, hr.HtmlResult);
            List <WebLink> wls = ags.GetWebLinks(WebLinkType.Anchor | WebLinkType.Area | WebLinkType.Form | WebLinkType.MetaTag | WebLinkType.Frame | WebLinkType.Image | WebLinkType.Javascript);
            List <WebLink> beyond_domain_web_links;

            wls = Spider.GetSpiderableLinks(ags.BaseUri, wls, out beyond_domain_web_links);
            bool download = true;

            if (depth2 >= Bot.Properties.Spider.Default.MaxDownloadLinkDepth)
            {
                download = false;
            }
            foreach (WebLink wl in wls)
            {
                bc.Add(new Link(url: wl.Url, depth: depth2, download: download));
                page_count++;
                if (Bot.Properties.Spider.Default.MaxPageCountPerSite > -1 && Bot.Properties.Spider.Default.MaxPageCountPerSite <= page_count)
                {
                    Log.Warning(domain + " reached MaxPageCountPerSite: " + Bot.Properties.Spider.Default.MaxPageCountPerSite.ToString());
                    break;
                }
            }
            domain2page_count[domain] = page_count;
            foreach (WebLink wl in beyond_domain_web_links)
            {
                bc.Add(new Link(url: wl.Url, depth: depth2, download: false));
            }
        }
コード例 #4
0
        public void get_links(int depth2, string queue)
        {
            if (depth2 > Bot.Properties.Spider.Default.MaxDownloadLinkDepth)
            {
                return;
            }

            string domain     = Spider.GetDomain(hr.ResponseUrl);
            int    page_count = domain2page_count[domain];

            if (Bot.Properties.Spider.Default.MaxPageCountPerSite > -1 && page_count >= Bot.Properties.Spider.Default.MaxPageCountPerSite)
            {
                return;
            }
            string queue2 = domain + "-" + depth2.ToString();

            if (depth2 > 1)
            {
                Session.SetInputItemQueuePositionAfterQueue(queue2, queue);//by default queue name is item type name but it can be different if needed
            }
            AgileSpider    ags = new AgileSpider(hr.ResponseUrl, hr.HtmlResult);
            List <WebLink> wls = ags.GetWebLinks(WebLinkType.Anchor | WebLinkType.Area | WebLinkType.Form | WebLinkType.MetaTag | WebLinkType.Frame | WebLinkType.Image | WebLinkType.Javascript);
            List <WebLink> beyond_domain_web_links;

            wls = Spider.GetSpiderableLinks(ags.BaseUri, wls, out beyond_domain_web_links);
            bool download = true;

            if (depth2 >= Bot.Properties.Spider.Default.MaxDownloadLinkDepth)
            {
                download = false;
            }
            foreach (WebLink wl in wls)
            {
                BotCycle.Add(queue2, new Link(url: wl.Url, depth: depth2, download: download));
                page_count++;
                if (Bot.Properties.Spider.Default.MaxPageCountPerSite > -1 && Bot.Properties.Spider.Default.MaxPageCountPerSite <= page_count)
                {
                    Log.Warning(domain + " reached MaxPageCountPerSite: " + Bot.Properties.Spider.Default.MaxPageCountPerSite.ToString());
                    break;
                }
            }
            domain2page_count[domain] = page_count;
            foreach (WebLink wl in beyond_domain_web_links)
            {
                BotCycle.Add(queue2, new Link(url: wl.Url, depth: depth2, download: false));//by default queue name is item type name but it can be deifferent if needed
            }
        }
コード例 #5
0
            override public void PROCESSOR(BotCycle bc)
            {
                CustomBot cb  = (CustomBot)bc.Bot;
                string    url = "http://www.rent.com/" + Regex.Replace(State, @"\s", "-");

                if (!cb.HR.GetPage(url))
                {
                    throw new ProcessorException(ProcessorExceptionType.RESTORE_AS_NEW, "Could not get: " + url);
                }

                DataSifter.Capture c = cities.Parse(cb.HR.HtmlResult);

                string[] us = c.ValuesOf("Url");
                for (int i = 0; i < us.Length; i++)
                {
                    bc.Add(new SearchItem("http://www.rent.com" + us[i]));
                }
            }
コード例 #6
0
        void search_processor(string url)
        {
            if (!HR.GetPage(url))
            {
                throw new ProcessorException(ProcessorExceptionType.RESTORE_AS_NEW, "Could not get: " + url);
            }

            DataSifter.Capture c0 = search.Parse(HR.HtmlResult);

            string npu = c0.ValueOf("NextPageUrl");

            if (npu != null)
            {
                BotCycle.Add(new SearchNextPageItem(npu));
            }

            foreach (DataSifter.Capture c in c0["Product"])
            {
                BotCycle.Add(new CompanyItem(Spider.GetAbsoluteUrl(c.ValueOf("Url"), url), c.ValueOf("Name"), c.ValueOf("City"), c.ValueOf("State"), c.ValueOf("Phone")));
            }
        }
コード例 #7
0
            override public void __Processor(BotCycle bc)
            {
                CustomSession session = (CustomSession)bc.Session;

                string address  = new System.Globalization.CultureInfo("en-US", false).TextInfo.ToTitleCase(Address.ToLower());
                string file_dir = PathRoutines.CreateDirectory(session.output_dir + "\\" + address, true);

                string output_pdf = file_dir + "\\" + Regex.Replace(address + " RPA.pdf", @"\s+", " ");
                {
                    //lock (template_pdf)
                    //{
                    //    File.Copy(template_pdf, pdf);
                    //}

                    PdfReader.unethicalreading = true;
                    PdfReader pr = new PdfReader(template_pdf);
                    //pr.RemoveUsageRights();
                    //pr.SelectPages("7,8");
                    PdfStamper ps = new PdfStamper(pr, new FileStream(output_pdf, FileMode.Create, FileAccess.Write, FileShare.None));

                    //string fs = "";
                    //foreach (KeyValuePair<string, AcroFields.Item> kvp in ps.AcroFields.Fields)
                    //    fs += "\n{\"" + kvp.Key + "\", \"\"},";

                    set_field(ps.AcroFields, "Todays Date", DateTime.Today.ToShortDateString());
                    set_field(ps.AcroFields, "Buyer Name", Settings.Parties.BuyerProfile.Name);
                    set_field(ps.AcroFields, "Address and Unit Number", address + " " + UnitNumber);
                    set_field(ps.AcroFields, "City/Town", City);
                    //set_field(ps.AcroFields, "CLARK", );
                    set_field(ps.AcroFields, "Zip", ZipCode);
                    set_field(ps.AcroFields, "PARCEL NUMBER", ParcelNumber);
                    set_field(ps.AcroFields, "OfferAmt", OfferAmt);
                    string offer_amt_ = Regex.Replace(OfferAmt, @"[^\d]", "");
                    if (offer_amt_.Length > 0)
                    {
                        set_field(ps.AcroFields, "OfferAmt in words", ConvertionRoutines.NumberToWords(int.Parse(offer_amt_)).ToUpper());
                    }
                    set_field(ps.AcroFields, "EMD", Settings.Offer.Emd);
                    //set_field(ps.AcroFields, "Check Box1", );
                    //set_field(ps.AcroFields, "Balance", );
                    set_field(ps.AcroFields, "Co Buyer Name", Settings.Parties.BuyerProfile.CoBuyerName);
                    set_field(ps.AcroFields, "<address> <UnitNumber> <City/town> NV <ZIP Code>", address + " " + UnitNumber + ", " + City + " NV " + ZipCode);
                    set_field(ps.AcroFields, "ML#", "ALL PER ML# " + ML_Id);
                    set_field(ps.AcroFields, "Title Company", Settings.Parties.EscrowProfile.TitleCompany);
                    set_field(ps.AcroFields, "Escrow Officer", Settings.Parties.EscrowProfile.Officer);
                    set_field(ps.AcroFields, "Close of Escrow", Settings.Offer.CloseOfEscrow.ToShortDateString());

                    //String[] values = ps.AcroFields.GetAppearanceStates("Licensee Yes");
                    //String[] values2 = ps.AcroFields.GetAppearanceStates("Licensee No");
                    if (Settings.Parties.BuyerProfile.UseLicensee)
                    {
                        set_field(ps.AcroFields, "Licensee Yes", "Yes");
                        //set_field(ps.AcroFields, "Licensee No", "Off");
                        //set_field(ps.AcroFields, "Licensee relationship", DateTime.Today.ToShortDateString());
                        set_field(ps.AcroFields, "Licensee relationship", Settings.Parties.BuyerProfile.LicenseeRelationship);
                        switch (Settings.Parties.BuyerProfile.RelationshipType)
                        {
                        case "Family Firm":
                            set_field(ps.AcroFields, "Licensee Family Firm", "Yes");
                            break;

                        case "Principal":
                            set_field(ps.AcroFields, "Licensee Principal", "Yes");
                            break;
                        }
                    }
                    else
                    {
                        set_field(ps.AcroFields, "Licensee No", "Yes");
                        //set_field(ps.AcroFields, "Licensee Yes", "Off");
                    }

                    DateTime date = DateTime.Now.AddDays(7);
                    set_field(ps.AcroFields, "Response Month", date.ToString("MMMM"));
                    set_field(ps.AcroFields, "Response day", date.ToString("%d"));
                    set_field(ps.AcroFields, "year", date.ToString("yyyy"));;
                    string emd_ = Regex.Replace(Settings.Offer.Emd, @"[^\d]", "");
                    if (offer_amt_.Length > 0 && emd_.Length > 0)
                    {
                        set_field(ps.AcroFields, "Balance", (int.Parse(offer_amt_) - int.Parse(emd_)).ToString());
                    }

                    //                    string AdditionalTerms = @"This form is available for use by the real estate industry. It is not intended to identify the user as a REALTOR®.
                    //8 REALTOR® is a registered collective membership mark which may be used only by members of the NATIONAL
                    //9 ASSOCIATION OF REALTORS® who subscribe to its Code.";
                    string s = AdditionalTerms;
                    s = fill_field_by_words(ps.AcroFields, "AdditionalTerms1", s);
                    s = fill_field_by_words(ps.AcroFields, "AdditionalTerms2", s);
                    s = fill_field_by_words(ps.AcroFields, "AdditionalTerms3", s);
                    if (s.Length > 0)
                    {
                        s = AdditionalTerms;
                        s = fill_field_by_chars(ps.AcroFields, "AdditionalTerms1", s);
                        s = fill_field_by_chars(ps.AcroFields, "AdditionalTerms2", s);
                        set_field(ps.AcroFields, "AdditionalTerms3", s);
                    }

                    set_field(ps.AcroFields, "Buyer Broker", Settings.Parties.BrokerProfile.Name);
                    set_field(ps.AcroFields, "Agent Name", Settings.Parties.AgentProfile.Name);
                    set_field(ps.AcroFields, "ListAgentFullName", ListAgentFullName);
                    set_field(ps.AcroFields, "Company Name", Settings.Parties.BrokerProfile.Company);
                    set_field(ps.AcroFields, "ListOfficeName", ListOfficeName);
                    set_field(ps.AcroFields, "Agents License", Settings.Parties.AgentProfile.LicenseNo);
                    set_field(ps.AcroFields, "Brokers License", Settings.Parties.BrokerProfile.LicenseNo);
                    set_field(ps.AcroFields, "Office Address", Settings.Parties.BrokerProfile.Address);
                    set_field(ps.AcroFields, "Office Phone", Settings.Parties.BrokerProfile.Phone);
                    set_field(ps.AcroFields, "City State Zip", Settings.Parties.BrokerProfile.City + " " + Settings.Parties.BrokerProfile.State + " " + Settings.Parties.BrokerProfile.Zip);
                    set_field(ps.AcroFields, "Agent Email", Settings.Parties.AgentProfile.Email);
                    //set_field(ps.AcroFields, "Response Month", );
                    //set_field(ps.AcroFields, "Response day", );
                    //set_field(ps.AcroFields, "year", );
                    //set_field(ps.AcroFields,  "Date_2", );
                    //set_field(ps.AcroFields, "Date_3", );
                    //set_field(ps.AcroFields, "Sellers Broker", );
                    set_field(ps.AcroFields, "Agents Name_2", Settings.Parties.AgentProfile.Name);
                    set_field(ps.AcroFields, "Company Name_2", Settings.Parties.BrokerProfile.Company);
                    set_field(ps.AcroFields, "Agents License Number_2", Settings.Parties.AgentProfile.LicenseNo);
                    set_field(ps.AcroFields, "Brokers License Number_2", Settings.Parties.BrokerProfile.LicenseNo);
                    set_field(ps.AcroFields, "Office Address_2", Settings.Parties.BrokerProfile.Address);
                    set_field(ps.AcroFields, "Phone_2", Settings.Parties.BrokerProfile.Phone);
                    set_field(ps.AcroFields, "City State Zip_2", Settings.Parties.BrokerProfile.Zip);
                    set_field(ps.AcroFields, "Email_2", Settings.Parties.AgentProfile.Email);
                    set_field(ps.AcroFields, "ListAgentEmail", ListAgentEmail);

                    ps.FormFlattening = true;

                    for (int i = 1; i <= pr.NumberOfPages; i++)
                    {
                        var pcb = ps.GetOverContent(i);
                        add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.InitialFile), new System.Drawing.Point(497, 67));
                        if (Settings.Parties.BuyerProfile.UseCoBuyer)
                        {
                            add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.CoBuyerInitialFile), new System.Drawing.Point(536, 67));
                        }
                    }
                    {
                        var pcb = ps.GetOverContent(3);
                        add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.InitialFile), new System.Drawing.Point(140, 103));
                        if (Settings.Parties.BuyerProfile.UseCoBuyer)
                        {
                            add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.CoBuyerInitialFile), new System.Drawing.Point(280, 103));
                        }
                    }
                    {
                        var pcb = ps.GetOverContent(9);
                        add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.SignatureFile), new System.Drawing.Point(60, 190));
                        if (Settings.Parties.BuyerProfile.UseCoBuyer)
                        {
                            add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.CoBuyerSignatureFile), new System.Drawing.Point(60, 155));
                        }
                    }

                    ps.Close();
                    pr.Close();
                }

                string output_addendum_pdf = null;

                if (Settings.Offer.ShortSaleAddendum)
                {
                    output_addendum_pdf = file_dir + "\\" + Regex.Replace(address + " SS Addendum.pdf", @"\s+", " ");

                    PdfReader.unethicalreading = true;
                    PdfReader  pr = new PdfReader(template_addendum_pdf);
                    PdfStamper ps = new PdfStamper(pr, new FileStream(output_addendum_pdf, FileMode.Create, FileAccess.Write, FileShare.None));

                    string fs = "";
                    foreach (KeyValuePair <string, AcroFields.Item> kvp in ps.AcroFields.Fields)
                    {
                        fs += "\n{\"" + kvp.Key + "\", \"\"},";
                    }

                    if (Settings.Parties.BuyerProfile.UseCoBuyer)
                    {
                        set_field(ps.AcroFields, "<Buyer Name> and <Co Buyer Name>", Settings.Parties.BuyerProfile.Name + " and " + Settings.Parties.BuyerProfile.CoBuyerName);
                    }
                    else
                    {
                        set_field(ps.AcroFields, "<Buyer Name> and <Co Buyer Name>", Settings.Parties.BuyerProfile.Name);
                    }
                    set_field(ps.AcroFields, "Todays Date", DateTime.Today.ToShortDateString());
                    set_field(ps.AcroFields, "<Address> <UnitNumber> <City/Town> NV <Zip Code>", address + " " + UnitNumber + ", " + City + " NV " + ZipCode);
                    set_field(ps.AcroFields, "Agent Name", Settings.Parties.AgentProfile.Name);
                    //set_field(ps.AcroFields, "Agent Phone", );

                    ps.FormFlattening = true;

                    for (int i = 1; i <= pr.NumberOfPages; i++)
                    {
                        var pcb = ps.GetOverContent(i);
                        add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.InitialFile), new System.Drawing.Point(120, 70));
                        if (Settings.Parties.BuyerProfile.UseCoBuyer)
                        {
                            add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.CoBuyerInitialFile), new System.Drawing.Point(157, 70));
                        }
                    }
                    {
                        var pcb = ps.GetOverContent(1);
                        add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.InitialFile), new System.Drawing.Point(140, 400));
                        if (Settings.Parties.BuyerProfile.UseCoBuyer)
                        {
                            add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.CoBuyerInitialFile), new System.Drawing.Point(197, 400));
                        }
                    }
                    {
                        var pcb = ps.GetOverContent(3);
                        add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.SignatureFile), new System.Drawing.Point(150, 547));
                        if (Settings.Parties.BuyerProfile.UseCoBuyer)
                        {
                            add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.CoBuyerSignatureFile), new System.Drawing.Point(150, 504));
                        }
                    }

                    ps.Close();
                    pr.Close();
                }

                string output_addendum1_pdf = null;

                if (Settings.Offer.OtherAddendum1)
                {
                    output_addendum1_pdf       = file_dir + "\\" + Regex.Replace("duites " + address + ".pdf", @"\s+", " ");
                    PdfReader.unethicalreading = true;
                    PdfReader  pr = new PdfReader(template_addendum1_pdf);
                    PdfStamper ps = new PdfStamper(pr, new FileStream(output_addendum1_pdf, FileMode.Create, FileAccess.Write, FileShare.None));

                    string fs = "";
                    foreach (KeyValuePair <string, AcroFields.Item> kvp in ps.AcroFields.Fields)
                    {
                        fs += "\n{\"" + kvp.Key + "\", \"\"},";
                    }

                    set_field(ps.AcroFields, "AgentName", Settings.Parties.AgentProfile.Name);
                    set_field(ps.AcroFields, "LicenseNumber", Settings.Parties.AgentProfile.LicenseNo);
                    set_field(ps.AcroFields, "Buyer Name", Settings.Parties.BuyerProfile.Name);
                    set_field(ps.AcroFields, "Co-Buyer Name", Settings.Parties.BuyerProfile.CoBuyerName);
                    set_field(ps.AcroFields, "BrokerName", Settings.Parties.BrokerProfile.Name);
                    set_field(ps.AcroFields, "Company", Settings.Parties.BrokerProfile.Company);
                    set_field(ps.AcroFields, "Date_3", DateTime.Now.ToShortDateString());
                    set_field(ps.AcroFields, "Time_3", DateTime.Now.ToShortTimeString());
                    set_field(ps.AcroFields, "Date_4", DateTime.Now.ToShortDateString());
                    set_field(ps.AcroFields, "Time_4", DateTime.Now.ToShortTimeString());

                    ps.FormFlattening = true;

                    {
                        var pcb = ps.GetOverContent(1);
                        add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.InitialFile), new System.Drawing.Point(70, 190));
                        if (Settings.Parties.BuyerProfile.UseCoBuyer)
                        {
                            add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.CoBuyerInitialFile), new System.Drawing.Point(140, 190));
                        }
                    }
                    {
                        var pcb = ps.GetOverContent(1);
                        add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.SignatureFile), new System.Drawing.Point(110, 85));
                        if (Settings.Parties.BuyerProfile.UseCoBuyer)
                        {
                            add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.CoBuyerSignatureFile), new System.Drawing.Point(110, 85));
                        }
                    }

                    ps.Close();
                    pr.Close();
                }

                bc.Add(new EmailItem(output_pdf, output_addendum_pdf, output_addendum1_pdf));
            }