Пример #1
0
 private static string GrCoverLink(string query)
 {
     try
     {
         Uri             uri        = new Uri("http://www.goodreads.com/");
         Uri             url        = new Uri(uri.ToString() + "search?utf8=✓&query=" + query);
         BiblioUpTik.Web web        = new BiblioUpTik.Web();
         string          strSource1 = web.BookRequest(url);
         string          str        = new Uri(new Uri(uri.ToString() + "/book/show/").ToString() + web.GetStringBetween(strSource1, "<img id=\"coverImage\"", "/>", 0)).ToString();
         int             startIndex = str.IndexOf("src=\"") + 5;
         int             length     = str.LastIndexOf('"') - startIndex;
         try
         {
             return(str.Substring(startIndex, length));
         }
         catch (Exception ex)
         {
             string strSource2 = new BiblioUpTik.Web().BookRequest(new Uri(new Uri("http://www.overdrive.com/").ToString() + "search?q=" + query));
             return(new Uri(web.GetStringBetween(strSource2, "<img not-data-src=\"/Content/img/load.gif\" src=\"", "\"", 0)).ToString());
         }
     }
     catch (Exception ex)
     {
         return("");
     }
 }
Пример #2
0
 public Color DupeCheck(ListViewItem item)
 {
     try
     {
         BiblioUpTik.Web web = new BiblioUpTik.Web();
         this._w.Navigate(BiblioSite.SearchUrl(item));
         this.LoadWait();
         string stringBetween = web.GetStringBetween(this._w.DocumentText, "<tbody>", "</tbody>", 0);
         int    num           = BiblioSite.CountOccurences("<span class=\"title\">", stringBetween);
         int    Start         = 1;
         for (int index = 0; index < num; ++index)
         {
             if (web.GetStringBetween(stringBetween, "<td>", "</td>", Start).Contains("[Retail]"))
             {
                 return(Color.Red);
             }
             if (index + 1 == num)
             {
                 return(item.Tag.ToString().Split('|')[1].Trim().Equals("retail") ? Color.Green : Color.Teal);
             }
             Start += 8;
         }
         return(Color.Green);
     }
     catch (Exception ex)
     {
         int num = (int)MessageBox.Show(ex.ToString());
         return(Color.Black);
     }
 }
Пример #3
0
 public static string AzCoverLink(string query)
 {
     try
     {
         Uri             url            = new Uri(new Uri("http://www.amazon.com/gp/product/images/").ToString() + query);
         BiblioUpTik.Web web            = new BiblioUpTik.Web();
         string          strSource      = web.BookRequest(url);
         string          stringBetween1 = web.GetStringBetween(strSource, "<noscript><div id=\"imageViewerDiv\">", "</div></noscript>", 0);
         string          stringBetween2 = web.GetStringBetween(stringBetween1, "<img src=\"", "\" id=", 0);
         int             startIndex     = stringBetween2.IndexOf('_') - 1;
         int             count          = stringBetween2.LastIndexOf('_') + 1 - startIndex;
         return(stringBetween2.Remove(startIndex, count));
     }
     catch (Exception ex)
     {
         return("");
     }
 }
Пример #4
0
 public static ListViewItem ScrapeMobiData(ListViewItem item)
 {
     try
     {
         string          query = item.Tag.ToString().Split('|')[2].Trim();
         BiblioUpTik.Web web   = new BiblioUpTik.Web();
         try
         {
             Uri url = new Uri(new Uri("http://www.amazon.com/dp/").ToString() + query);
             if (BiblioUpTik.Properties.Settings.Default.GetPublisher || BiblioUpTik.Properties.Settings.Default.GetPages)
             {
                 string strSource = web.BookRequest(url);
                 if (BiblioUpTik.Properties.Settings.Default.GetPublisher)
                 {
                     item.SubItems[4].Text = web.GetStringBetween(strSource, "<b>Publisher:</b>", ";", 0).Replace(",", "").Trim();
                 }
                 if (BiblioUpTik.Properties.Settings.Default.GetPages && int.Parse(item.SubItems[8].Text) <= 0)
                 {
                     item.SubItems[8].Text = web.GetStringBetween(strSource, "<b>Print Length:</b>", " pages", 0).Trim();
                 }
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine((object)ex);
         }
         if (BiblioUpTik.Properties.Settings.Default.GetCover || BiblioUpTik.Properties.Settings.Default.GetDescription)
         {
             GoogleBook googleBook = string.IsNullOrWhiteSpace(item.SubItems[6].Text) ? new GoogleBook(item, false) : new GoogleBook(item, true);
             bool       flag       = googleBook.VolumeInfo() != null;
             if (BiblioUpTik.Properties.Settings.Default.GetDescription && flag)
             {
                 item.SubItems[7].Text = googleBook.Description() ?? item.SubItems[7].Text;
             }
             if (BiblioUpTik.Properties.Settings.Default.GetCover)
             {
                 if (query != "")
                 {
                     item.SubItems[9].Text = Book.AzCoverLink(query);
                 }
                 else if (!string.IsNullOrWhiteSpace(item.SubItems[6].Text))
                 {
                     item.SubItems[9].Text = Book.AzCoverLink(Book.ConvertToISBN10(item.SubItems[6].Text));
                 }
                 if (string.IsNullOrWhiteSpace(item.SubItems[9].Text) && query != "")
                 {
                     item.SubItems[9].Text = Book.GrCoverLink(query);
                 }
             }
             if (!string.IsNullOrWhiteSpace(item.SubItems[6].Text) && flag)
             {
                 if (string.IsNullOrWhiteSpace(item.SubItems[5].Text))
                 {
                     item.SubItems[5].Text = googleBook.PublishDate() ?? "";
                 }
                 if (string.IsNullOrWhiteSpace(item.SubItems[2].Text))
                 {
                     item.SubItems[2].Text = googleBook.Author() ?? "";
                 }
                 if (string.IsNullOrWhiteSpace(item.SubItems[3].Text))
                 {
                     item.SubItems[3].Text = googleBook.Title() ?? "";
                 }
             }
         }
         return(item);
     }
     catch (Exception ex)
     {
         return(item);
     }
 }