How to do a screenshot an entire page ?

  • Автор темы Автор темы Perfecto
  • Дата начала Дата начала

Perfecto

Client
Регистрация
06.08.2013
Сообщения
108
Реакции
9
Баллы
18
I know how to capture a captcha with captchasaver but not the entire page.
 
Код:
Развернуть Свернуть Копировать
HtmlElement he = instance.ActiveTab.FindElementByAttribute("body","fulltag","body","text",0);
int heHeight = Convert.ToInt32(he.GetAttribute("height"));
int heWidth = Convert.ToInt32(he.GetAttribute("width"));
int step =2000;
int countOfIterations = heHeight/step;
var bitmaps = new List<System.Drawing.Bitmap>();
int count =0;
for(int i =0;i<countOfIterations;i++)
{
    var text = he.DrawPartToBitmap(0, i*step, heWidth, step, true);
    byte[] imageBytes = Convert.FromBase64String(text);
    var ms = new System.IO.MemoryStream(imageBytes, 0, imageBytes.Length);
    var img = (System.Drawing.Bitmap)System.Drawing.Image.FromStream(ms);
    img.Save(@"{-Project.Directory-}"+@"Images\"+project.Variables["Name"].Value+i.ToString()+@".jpg");
    count++;
}
int lastPieceHeight = heHeight%step;
if (lastPieceHeight>10)
{
    var text = he.DrawPartToBitmap(0, heHeight-lastPieceHeight, heWidth, lastPieceHeight, true);
    byte[] imageBytes = Convert.FromBase64String(text);
    var ms = new System.IO.MemoryStream(imageBytes, 0, imageBytes.Length);
    var img = (System.Drawing.Bitmap)System.Drawing.Image.FromStream(ms);
    img.Save(@"{-Project.Directory-}"+@"Images\"+project.Variables["Name"].Value+@".jpg");
}
 
Код:
Развернуть Свернуть Копировать
HtmlElement he = instance.ActiveTab.FindElementByAttribute("body","fulltag","body","text",0);
int heHeight = Convert.ToInt32(he.GetAttribute("height"));
int heWidth = Convert.ToInt32(he.GetAttribute("width"));
int step =2000;
int countOfIterations = heHeight/step;
var bitmaps = new List<System.Drawing.Bitmap>();
int count =0;
for(int i =0;i<countOfIterations;i++)
{
    var text = he.DrawPartToBitmap(0, i*step, heWidth, step, true);
    byte[] imageBytes = Convert.FromBase64String(text);
    var ms = new System.IO.MemoryStream(imageBytes, 0, imageBytes.Length);
    var img = (System.Drawing.Bitmap)System.Drawing.Image.FromStream(ms);
    img.Save(@"{-Project.Directory-}"+@"Images\"+project.Variables["Name"].Value+i.ToString()+@".jpg");
    count++;
}
int lastPieceHeight = heHeight%step;
if (lastPieceHeight>10)
{
    var text = he.DrawPartToBitmap(0, heHeight-lastPieceHeight, heWidth, lastPieceHeight, true);
    byte[] imageBytes = Convert.FromBase64String(text);
    var ms = new System.IO.MemoryStream(imageBytes, 0, imageBytes.Length);
    var img = (System.Drawing.Bitmap)System.Drawing.Image.FromStream(ms);
    img.Save(@"{-Project.Directory-}"+@"Images\"+project.Variables["Name"].Value+@".jpg");
}
Thank you very much but I preferred solution rostonix because I'm not a programmer
 
  • Спасибо
Реакции: bigcajones
Hi

I've got the following code:

Код:
Развернуть Свернуть Копировать
HtmlElement he = instance.ActiveTab.FindElementByAttribute("body","fulltag","body","text",0);
int heHeight = Convert.ToInt32(he.GetAttribute("height"));
int heWidth = Convert.ToInt32(he.GetAttribute("width"));
var bitmaps = new List<System.Drawing.Bitmap>();

    var text = he.DrawPartToBitmap(0, 0, heWidth, 3000, true);
    byte[] imageBytes = Convert.FromBase64String(text);
    var ms = new System.IO.MemoryStream(imageBytes, 0, imageBytes.Length);
    var img = (System.Drawing.Bitmap)System.Drawing.Image.FromStream(ms);
    img.Save(@"{-Project.Directory-}"+@"images2\"+project.Variables["Name"].Value+@".jpg");

It just takes one part of the webpage.
Though, I'd like the code to take the first part of an already existing image on the pc, instead of the webpage.
So I guess I'll need to change the first row of the code by something else, but I don't know what.
Is this possible, and if so, could anyone help?
Thanks.
 
double post...
 
Im not sure i understand what you want)
 
Well:
1) take image from pc: eg, {-Project.Directory-}images/image1.png
2) crop image, only take first x pixels in height; width stays same
3) save image in eg {-Project.Directory-}images-cropped/image1.png
 

Кто просматривает тему: (Всего: 0, Пользователи: 0, Гости: 0)