会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132482个问题
Python 全系列/第十八阶段:数据分析-数据可视化/Seaborn(23旧) 21706楼
JAVA 全系列/第三阶段:数据库编程/SQL 语言 21707楼
JAVA 全系列/第三阶段:数据库编程/JDBC技术(旧) 21708楼

mybatiswebdemo.zip

我的分页没有显示成功,请老师帮我看一下

JAVA 全系列/第六阶段:项目管理与SSM框架/Mybatis 21710楼
Python 全系列/第四阶段:函数式编程和核心特性/内存管理 21711楼

import requests
from fake_useragent import UserAgent
from bs4 import BeautifulSoup
from time import sleep

def get_list():
    num = int(input("请输入要获取多少页数据:"))
    for i in range(num):
        url = "https://maoyan.com/films?showType=3&offset={i*30}"
        headers = {'User-Agent':UserAgent().chrome}
        resp = requests.get(url,headers=headers)
        soup = BeautifulSoup(resp.text,'lxml')
        all_a = soup.select('div > a[data-act="movies-click"]')
        print(all_a)
        return [a.get('href') for a in all_a]

# 格式化演员集合,去重
def format_actors(a_list):
    actor_set = set()
    for a in a_list:
        actor_set.add(a.text.strip())       # 需要a标签里的文本,去除空格
    return actor_set

def start():
    all_href = get_list()
    for a in all_href:
        sleep(2)
        url = f"https://maoyan.com{a}"
        headers = {'User-Agent':UserAgent().chrome}
        resp = requests.get(url,headers=headers)
        soup = BeautifulSoup(resp.text,'lxml')

        name = soup.select('h1.name')[0].text.strip()
        types = soup.select('li.ellipsis')[0].text.strip()
        actors_m = soup.select('li.celebrity.actor > div > a')
        actors = format_actors(actors_m)
        print(f'电影名:{name}  电影类型:{types}   演员:{actors}')

if __name__ == '__main__':
    start()

老师,帮我看看这是为什么?我的输出没有结果!

图片.png

Python 全系列/第十五阶段:Python 爬虫开发/爬虫基础(旧) 21712楼

    public boolean regionMatches(boolean ignoreCase, int toffset,
            String other, int ooffset, int len) {
        char ta[] = value;
        int to = toffset;
        char pa[] = other.value;
        int po = ooffset;
        // Note: toffset, ooffset, or len might be near -1>>>1.
        if ((ooffset < 0) || (toffset < 0)
                || (toffset > (long)value.length - len)
                || (ooffset > (long)other.value.length - len)) {
            return false;
        }
        while (len-- > 0) {
            char c1 = ta[to++];
            char c2 = pa[po++];
            if (c1 == c2) {
                continue;
            }
            if (ignoreCase) {
                // If characters don't match but case may be ignored,
                // try converting both characters to uppercase.
                // If the results match, then the comparison scan should
                // continue.
                char u1 = Character.toUpperCase(c1);
                char u2 = Character.toUpperCase(c2);
                if (u1 == u2) {
                    continue;
                }
                // Unfortunately, conversion to uppercase does not work properly
                // for the Georgian alphabet, which has strange rules about case
                // conversion.  So we need to make one last check before
                // exiting.
                if (Character.toLowerCase(u1) == Character.toLowerCase(u2)) {
                    continue;
                }
            }
            return false;
        }
        return true;
    }

老师?String源码中的这一段

    public boolean regionMatches(boolean ignoreCase, int toffset,
            String other, int ooffset, int len) {
        char ta[] = value;
        int to = toffset;
        char pa[] = other.value;
        int po = ooffset;

为什么不直接使用传进来的形参,而是再声明另外的变量,赋值。

再操作新声明的变量。

为什么绕這莫一大圈呢?

JAVA 全系列/第二阶段:JAVA 基础深化和提高/常用类 21713楼
JAVA 全系列/第三阶段:数据库编程/Oracle 数据库的使用 21715楼
Python 全系列/第八阶段:轻量级Web开发利器-Flask框架/Flask数据库 21716楼
Python 全系列/第八阶段:轻量级Web开发利器-Flask框架/Flask数据库 21717楼
Python 全系列/第一阶段:Python入门/Python入门(动画版) 21718楼
JAVA 全系列/(旧的隐藏)第十阶段:spring全家桶(SpringData)/Spring Data 21720楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637