zoukankan      html  css  js  c++  java
  • 一些面试问题以及一些解法

    玖富火眼python爬虫工程师面试题

    2017.12可以百度谷歌搜索,可以微信电话求助

    1

    S1 = u'xe6x97xa0xe5x90x8d'

    S2 = 'xe6x97xa0xe5x90x8d'

    分别在win环境和linux环境下输出为中文

     from urllib import parse
    S1 = u'xe6x97xa0xe5x90x8d'
    s2 = S1.encode('raw_unicode_escape').decode('utf8')
    print(s2)
    S2 = 'xe6x97xa0xe5x90x8d'
    print(S2.encode('raw_unicode_escape').decode('utf8'))

     目前这两个输出的东西一样,应该是有问题,但是至少符合题意

    参考 http://www.cnblogs.com/fanjp666888/p/7797720.html

    2

    html_str = """

    <div id="box1">this from blog.csdn.net/lncxydjq , DO NOT COPY!

        <div id="box2">*****

            <!--can u get me, bitch?-->

        </div>

    </div>

    """

    分别用xpath beautifulsoup 正则 获取lxml文档中的注释

     # 第二题
    from bs4 import BeautifulSoup
    import re
    from lxml import etree
    contents = """
    <div id="box1">this from blog.csdn.net/lncxydjq , DO NOT COPY!
    <div id="box2">*****
    <!--can u get me, bitch?-->
    </div>
    </div>
    """
    demo = re.compile('<!--(.*?)-->',re.S)
    lists = demo.findall(contents)
    print(lists[0])

    print (etree.HTML(contents).xpath('//div[@id="box1"]/div/node()')[1].text)

    soup = BeautifulSoup(contents,'lxml')
    a = soup.find_all('div',id='box2')
    for i in a:
    print(i.contents[1])

    3

    import requests

    url = 'http://xyzfgjj.xys.gov.cn/chaxun_geren.asp'

    response = requests.get(url)

    print response.text # 乱码

    print response.content # 乱码

    # 输出如下:

    # <td><font color="#ff0000">µ±Ç°Î»Öãº</font><a href="index.asp">Ê×Ò³

    # </a>&nbsp;&gt;&gt;&nbsp;¸öÈËÕÊ»§²éѯ</td>

    让其输出为中文

     # 第三题
    import requests
    url = 'http://xyzfgjj.xys.gov.cn/chaxun_geren.asp'
    response = requests.get(url)
    print(response.content.decode('gbk')) # 乱码

    4

    如何在生产环境中 对限定使用ie浏览器 activeX密码登录控件 的银行网站 做网银登录?

     暂无标准答案,目测可以使用调取接口的方式生成cookie

    5

    基于tornado写出一个或多个异步协程爬虫demo,展示点:get请求,post请求,获取/更新cookies,设置/获取完整请求头信息 

    这个网上有例子,但是由于之前没有用过这个框架,短时间看的不太能接受,以后慢慢研究

    https://blog.csdn.net/WuLex/article/details/78398304

    6

    用除了python以外的其他语言写个helloworld

    Alert(‘hello world’)

    Printf(‘hello world’);

    <?php

    Print(‘hello world’)

    ?>

  • 相关阅读:
    Response.Redirect引起的性能问题分析
    Html5中 视频 音频标签 进度条问题
    GIS 地理坐标分类
    函数指针理解最透彻的文章
    python安装第三方包之后无法导入相应模块(一个容易忽略的bug)
    git使用入门
    OpenSSL中HMAC,MD5以及对称加密算法的应用
    OpenSSL库中加密组件使用的相关链接
    Ubuntu 12.04LTS下配置OpenSSL和gmp环境
    编程写作注意事项!
  • 原文地址:https://www.cnblogs.com/mypath/p/9361362.html
Copyright © 2011-2022 走看看