如何使用请求获取html代码的注释部分?

时间:2020-04-23 08:20:50

标签: python html beautifulsoup

我正在尝试获取一个Facebook页面的追随者数量,即https://web.facebook.com/marlenaband。我正在使用python [HttpPost] public ActionResult ForgotPassword(string EmailID) { string resetCode = Guid.NewGuid().ToString(); var verifyUrl = "/Account/ResetPassword/" + resetCode; var link = Request.Url.AbsoluteUri.Replace(Request.Url.PathAndQuery, verifyUrl); //get user details from database. using (var context = new LoginRegistrationInMVCEntities()) { var getUser = (from s in context.RegisterUsers where s.Email == EmailID select s).FirstOrDefault(); if (getUser != null) { getUser.ResetPasswordCode = resetCode; //This line I have added here to avoid confirm password not match issue , as we had added a confirm password property context.Configuration.ValidateOnSaveEnabled = false; context.SaveChanges(); var subject = "Password Reset Request"; var body = "Hi " + getUser.FirstName + ", <br/> You recently requested to reset your password for your account. Click the link below to reset it. " + " <br/><br/><a href='" + link + "'>" + link + "</a> <br/><br/>" + "If you did not request a password reset, please ignore this email or reply to let us know.<br/><br/> Thank you"; SendEmail(getUser.Email, body, subject); ViewBag.Message = "Reset password link has been sent to your email id."; } else { ViewBag.Message = "User doesn't exists."; return View(); } } return View(); } private void SendEmail(string emailAddress, string body, string subject) { using (MailMessage mm = new MailMessage("youremail@gmail.com", emailAddress)) { mm.Subject = subject; mm.Body = body; mm.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.EnableSsl = true; NetworkCredential NetworkCred = new NetworkCredential("youremail@gmail.com", "YourPassword"); smtp.UseDefaultCredentials = true; smtp.Credentials = NetworkCred; smtp.Port = 587; smtp.Send(mm); } } 库。当我在浏览器中看到页面源时,文本“ 142个人遵循此”似乎出现在页面的注释部分中。但是,我在使用requestsrequests的响应文本中没有看到它。有人能帮我得到这个吗?谢谢

这是我正在使用的代码:

BeautifulSoup

1 个答案:

答案 0 :(得分:0)

我实际上是通过将requests修改为headers来得到它的:

headers = {
    'accept-language':'en-US,en;q=0.8',
}