How to do a screenshot an entire page ?

Perfecto

Client
Регистрация
06.08.2013
Сообщения
94
Благодарностей
5
Баллы
8
I know how to capture a captcha with captchasaver but not the entire page.
 

bigcajones

Client
Регистрация
09.02.2011
Сообщения
1 216
Благодарностей
683
Баллы
113
Код:
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");
}
 

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 715
Баллы
113

Perfecto

Client
Регистрация
06.08.2013
Сообщения
94
Благодарностей
5
Баллы
8
Код:
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

bigcajones

Client
Регистрация
09.02.2011
Сообщения
1 216
Благодарностей
683
Баллы
113
Me neither, I'm a carpenter. :cj:
 
  • Спасибо
Реакции: Lexicon и rostonix

archel

Client
Регистрация
02.05.2011
Сообщения
175
Благодарностей
22
Баллы
18
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.
 

archel

Client
Регистрация
02.05.2011
Сообщения
175
Благодарностей
22
Баллы
18
double post...
 

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 715
Баллы
113
Im not sure i understand what you want)
 

archel

Client
Регистрация
02.05.2011
Сообщения
175
Благодарностей
22
Баллы
18
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)